Caddy2 matcher / rewrite / modx

Path doesn’t work because modx doesn’t understand q parameter starting with “/”

Okay after few hours it seems i have solved the puzzle
Here is the working solution:

root * /var/www/html/globus-furniture
encode zstd gzip
respond /core/* 404 {
    close
}
@pages {
    path_regexp modx ^/(.*)$
    file {
    	try_files {path} /index.php
    }
    not path /manager /manager/* /connectors/*
}
rewrite @pages {http.matchers.file.relative}?q={http.regexp.modx.1}
php_fastcgi unix//run/php/php7.4-fpm.sock
redir /index.php / permanent
file_server

The biggest challenge was to unite try_files and regexp

1 Like