1. The problem I’m having:
Hi, I’m trying to serve a PHP-FPM with Caddy as a reverse proxy. The PHP app and Caddy are in separate Docker containers. I managed to serve .php files with the php_fastcgi
directive but I don’t know how to deal with static resources.
As I understand, ideally I should give Caddy access to static files through a shared volume and serve them with file_server
. But the .php files and static files are not well organized (mixed in hundreds of directories…) and the dev team won’t change the architecture. It would imply to share a huge directory with the Caddy container, including sensitive data like .pem files.
Also, the app doesn’t have a unique “routing” index.php file. I have to access different ones from URI.
2. Error messages and/or full log output:
None
3. Caddy version:
Caddy v2.6.4
4. How I installed and ran Caddy:
From official Docker container caddy:2.6.4-alpine
a. System environment:
Docker compose (Debian 11 host)
d. My complete Caddy config:
route {
root * /var/www/html
php_fastcgi unix//var/run/php/php-fpm.sock
}
This config works only for .php files. Static files are returned a 404 error.
I also tried to send all requests to PHP-FPM with the following directive but it doesn’t work (error 502) : reverse_proxy * unix//var/run/php/php-fpm.sock
Is there a way to serve static files through php-fpm with Caddy?