Caddy not serving my PHP app

1. Output of caddy version:

v2.5.2 h1:eCJdLyEyAGzuQTa5Mh3gETnYWDClo1LjtQm2q9RNZrs=

2. How I run Caddy:

# /etc/supervisor/conf.d/caddy.conf

[program:caddy]
command=$(which caddy) run --environ --config /etc/caddy/Caddyfile
user=user
auto_start=true
autorestart=true
startsecs=1
startretries=3
stopsignal=QUIT
stopwaitsecs=10
stopasgroup=true
killasgroup=true
redirect_stderr=true
stdout_logfile=/home/app/.logs/caddy.log
stderr_logfile=/home/app/.logs/caddy-err.log

a. System environment:

Ubuntu 20
PHP 8.1

b. Command:

Paste command here.

c. Service/unit/compose file:

Paste full file contents here.
Make sure backticks stay on their own lines,
and the post looks nice in the preview pane. -->

d. My complete Caddy config:

:80 {
        root * /home/app/default/public

        encode gzip
	    file_server

        php_fastcgi unix:/var/run/php/php-fpm.sock
}
Paste your config here, replacing this text.
Use `caddy fmt` to make it readable.
DO NOT REDACT anything except credentials.
LEAVE DOMAIN NAMES INTACT.
Make sure the backticks stay on their own lines.

3. The problem I’m having:

When I install caddy and configure it to run as a service, it runs well and I’m able to see the default caddy page when I type in my server ip.
When I override the default config and replace it with mine (see code above), I get:
This page isn’t working
IP_ADDRESS is currently unable to handle this request.

I’m currently migrating away from Nginx, but all my efforts since yesterday have been futile.

Screen Shot 2022-09-04 at 08.07.26

Caddy seems to be running fine when I check its status and everything else.
No error logs.

4. Error messages and/or full log output:

Paste logs/commands/output here.
USE THE PREVIEW PANE TO MAKE SURE IT LOOKS NICELY FORMATTED.

5. What I already tried:

  • I copied the same configs that come with the default Caddyfile, and added the php_fastcgi directives
  • Re-install caddy and php
  • Restarted my server
  • Re-read the docs and followed similar blog posts

6. Links to relevant resources:

Weird, I simply changed my Caddyfile from what I have above to:

:80 

root * /home/app/default/public

encode gzip
file_server

php_fastcgi unix//var/run/php/php-fpm.sock

and it works now.

What could be the reason?

This is the difference. unix/ is the correct network prefix, unix: is not correct here.

1 Like

Thanks Francis.
I promise, I’ll get rid of this nginx in me :sweat_smile: