How to serve static files with Caddy next to PHP Script execution? (Symfony)

Viewed 580

I have a docker-compose based Server setup running PHP, Postgres and Caddy as Webserver/Reverse-Proxy with Auto-SSL that serves a PHP-Application (Framework Symfony 3/Sylius 1.5) with php5-fpm.

It works very well so far, but not with any static files like CSS, Images, JS and so on, although the file_server directive was placed. Any static content gets a 404.

My application is copied into the folder /srv/app, where /srv/app/public contains index.php and /srv/app/public/assets contains static files (including several sub-folders).

This is my Caddyfile:

{$SERVER_NAME}

log

route {
    root * /srv/app/public
    php_fastcgi unix//var/run/php/php-fpm.sock
    encode zstd gzip
    file_server
}

I have tried to specify folders for file_server directive like:

file_server assets/

or

file_server assets {
}

each within the route-branch.

But this way, Caddy won't serve anything and gives 500er.

How can I fix this?

0 Answers
Related