So after messing around for a few hours, i think a got a pretty good Caddy file for Flarum.
I thought I post it if anyone wants to use Caddy instead of Nginx and Apache.
Any suggestions for improvements are also welcome ?
www.example.com {
redir https://example.com{uri}
}
example.com {
root /var/www/flarum
rewrite {
if {path} match ^/admin
to {path} {path}/ /admin.php
}
rewrite {
if {path} match ^/api
to {path} {path}/ /api.php
}
rewrite {
to {path} {path}/ /index.php
}
rewrite {
if {path} match ^/(composer\.(json|lock)|config\.php|flarum|storage|vendor)
to /denyaccess
}
fastcgi / /var/run/php/php7.1-fpm.sock php {
ext .php
split .php
index index.php
}
header /assets {
+Cache-Control "public, must-revalidate, proxy-revalidate"
+Cache-Control "max-age=2592000"
Pragma "public"
}
gzip
}