Passing errors to a php script

Hi.

I’d like to handle certain errors with a PHP script.
I tried the following:

errors {
log /var/log/caddy/mysite_error.log
404 /error.php
}

However, this only outputs the raw script.
Any pointers?

Your PHP app will have to handle the errors; Caddy only deals with static files.

Having fastcgi set up and working, I figured if I told caddy to use a php-file for a 404 it would pass that on to fastcgi.

Not quite the case; Caddy just kind of hands it off and then it’s up to your backend to deal with the request. Good question though!

You will need an application level error handling for that. For now, out of Caddy’s scope.

Gotcha.

I was looking to migrate an old-ish php application to caddy that handles custom errors like that.
Coming from other webservers I’ve come to expect the server to honor the extension of the error document, so this took me a bit by surprise.

For now I’ll just try proxying to an nginx behind my caddyserver for this one site.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.