Handling errors globally

Output of caddy version: caddy v2.5.2

Why does caddy serve an empty response on error by default?
This is quite confusing, and as seen in the documentation it is a no-brainer to change. Caddy seems to aim for good defaults, and returning at least a simple error page seems a lot saner than a blank one.

And if that is not an option, is there a possibility to handle errors globally? I have multiple small sites, and would like to use the same error handler for all without copy-paste.

Because no error handler has been configured, so we don’t know what to put there. There are infinite possibilities! Unfortunately we can’t read the mind of the developer, so they will have to configure the error page, alas.

Use snippets! Then it’s a single import.

Note that often times repetition can be more easily avoided in elegant JSON configs than what the Caddyfile allows to express.

1 Like

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