I’m trying to convert the following Nginx config section to Caddy and I have no idea where to start really. I’m reading the rewrite section and fastcgi. It was very easy to get the PHP FPM working.
There are really only two main parts to the nginx config you’ve provided;
Rewrite from ^/(.*)$ to /index.php?url=$1, and;
FastCGI proxy php scripts to 127.0.0.1:9000
These two are super easy to replicate in a Caddyfile - the only somewhat complex part is the rewrite. You can give the rewrite directive the exact same regex string that nginx takes. However, instead of $1, $2 etc., Caddy’s regex substitutions take the form {1}, {2}, etc., so you need to modify the destination appropriately. Put it all together and you get:
rewrite {
regexp ^/(.*)$
to /index.php?url={1}
}
The fastcgi part is incredibly simple by comparison: