1. The problem I’m having:
Hello,
i have a Symfony project and wanted to switch from nginx to caddy because of te easyness of the ssl certificates, but i can’t get it to work, i’m just getting 404. But with nginx, it is working. I think both configs are very similar and i don’t understand why it is not working with caddy.
2. Error messages and/or full log output:
3. Caddy version:
2.7
4. How I installed and ran Caddy:
Using Docker
a. Caddy:
docker-compose.yml
version: '3.3'
services:
caddy:
container_name: caddy
image: caddy:2.7
volumes:
- './Caddyfile:/etc/caddy/Caddyfile'
restart: unless-stopped
ports:
- "80:80"
- "443:443"
- "443:443/udp"
networks:
default:
name: proxynet
external: true
Caddyfile
projectdomain {
root * /app/public
encode zstd gzip
file_server
php_fastcgi php-fpm:9000 {
resolve_root_symlink
}
@phpFile {
path *.php*
}
error @phpFile "Not found" 404
}
b. Nginx:
docker-compose.yml
version: '3.3'
services:
nginx:
image: nginx:1.25.2-alpine3.18
container_name: nginx
ports:
- "8034:80"
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf
networks:
default:
name: proxynet
external: true
nginx.conf
server {
listen 80;
server_name localhost;
root /app/public;
location / {
try_files $uri /index.php$is_args$args;
}
location ~ ^/index\.php(/|$) {
fastcgi_pass php-fpm:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $document_root;
internal;
}
error_log /var/log/nginx/project_error.log;
access_log /var/log/nginx/project_access.log;
}
Note: When i set a wrong fpm host in the Caddyfile, the result is the same.
I set it up using this guide.
Symfony Docs