Caddy v2.1.1: How to save php_fastcli err in logs?

1. Caddy version (caddy version):

Caddy v2.1.1

2. How I run Caddy:

Ubuntu 18.04 and php 7.3

With Caddy v1 in the logs I got errors that happened in php (php_fastcli), but with Caddy v2 logs I can’t see it. This is my Caddyfile:

domain.com {
        root * /var/www/app/index/
        log {
                output file /var/log/caddy/domain.com.log
                format json
                #format single_field common_log
                level DEBUG
        }
        php_fastcgi unix//run/php/php7.3-fpm.sock
        rewrite @apiPath /index.php?{query}&p={path}&s={http.regexp.apipath.1}
        encode gzip
        file_server
}

Any idea if I’m doing something wrong? Thanks for your time

This line doesn’t make sense - you didn’t define a named matcher @apiPath anywhere in your config, and there’s no regexp matcher anywhere that would give that regexp placeholder a value. Did you omit part of your config? Please post your entire config when asking for help.

As for the errors, you should look at the stdout output from Caddy. It depends on how you’re running Caddy where that would appear. You didn’t completely fill out the thread template, so all I can do is make assumptions. If you’re using Docker, then you could run docker logs caddy; if you installed Caddy using apt and it’s running as a service, then you could run journalctl -u caddy. If you ran it directly with caddy run, then you should see any errors right in your terminal.

We need more detail to be able to properly help.

1 Like

Was upgrading Caddy the only thing that changed on your system? If not, check that you have catch_workers_output set to yes in /etc/php/7.3/fpm/pool.d/www.conf (it is disabled by default).

I forgot to paste that part, this is the full example:

(apiRegex) {
    @apiPath {
            path_regexp apipath ^/api(\/.*)$
    }
}

domain.com {
        root * /var/www/app/index/
        import apiRegex
        log {
                output file /var/log/caddy/domain.com.log
                format json
                #format single_field common_log
                level DEBUG
        }
        php_fastcgi unix//run/php/php7.3-fpm.sock
        rewrite @apiPath /index.php?{query}&p={path}&s={http.regexp.apipath.1}
        encode gzip
        file_server
}

I also use the command journalctl -u caddy, but I didn’t get results either.

I have it activated, but I have nothing registered in the Caddy logs. :sweat_smile:

How are you running Caddy then? You didn’t fill out the issue template completely so we don’t have enough to go on to help you.

Sorry, I install Caddy using repository (I use Ubuntu 18.04 Server) and use “caddy reload” to use the config of my Caddyfile

Okay then you must be running Caddy as a systemctl service. Running journalctl -u caddy should work to get your logs.

Otherwise, there’s still not enough information here for us to help.

This topic was automatically closed after 30 days. New replies are no longer allowed.