Caddy2 & Symfony

Hello,

1. My Caddy version (2.0 beta13):

2. How I run Caddy:

caddy run --config /etc/caddy/Caddyfile --adapter caddyfile

a. System environment:

I run it in a container (docker) & through supervisord

d. My complete Caddyfile:

0.0.0.0:80 {
    root * /srv/public/

    try_files {path} /index.php/{path}?{query}

    php_fastcgi 127.0.0.1:9000
}

3. The problem I’m having:

I get a blank page for every requests (static file like php ones and even them that should be a 404):

$ curl -v localhost/favicon.ico
*   Trying ::1:80...
* TCP_NODELAY set
* Connected to localhost (::1) port 80 (#0)
> GET /favicon.ico HTTP/1.1
> Host: localhost
> User-Agent: curl/7.68.0
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Server: Caddy
< Date: Sat, 08 Feb 2020 21:42:44 GMT
< Content-Length: 0
< 
* Connection #0 to host localhost left intact
$ curl -v localhost/
*   Trying ::1:80...
* TCP_NODELAY set
* Connected to localhost (::1) port 80 (#0)
> GET / HTTP/1.1
> Host: localhost
> User-Agent: curl/7.68.0
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Server: Caddy
< Date: Sat, 08 Feb 2020 21:42:48 GMT
< Content-Length: 0
< 
* Connection #0 to host localhost left intact

Any idea what is not correct in my config ?
Thank you

Did you try without the try_files directive? The php_fastcgi directive implicitly has try_files {path} {path}/index.php index.php included which should be all you need. See https://caddyserver.com/docs/caddyfile/directives/php_fastcgi

To serve static files, you’ll need to add the file_server directive.

For example, this is what my Laravel app’s Caddyfile looks like:

:80 {
    root * /var/www/public

    encode gzip

    php_fastcgi php-fpm:9000

    file_server
}

Also,

is php-fpm running on 127.0.0.1:9000? This depends on the distribution.
If Caddy cannot find php-fpm, I think Caddy returns 502 instead of white screen.

1 Like

Hello,

Thanks for your time.
Even with yours advices, I can’t run it correctly.

You can try by yourself on PWD. Here is the step to start the project:

git clone https://github.com/mykiwi/symfony-with-caddy.git app -b caddy2
cd app
make build start db

My Caddyfile is in .docker/php/fs/etc/caddy/Caddyfile