Caddyfile v2 Error Directive

1. My Caddy version (caddy -version):

(devel) - version 2 (faf67b10)

2. How I run Caddy:

./caddy run

Loads a Caddyfile and runs
Running Ubuntu Linux 16.04, but that’s besides the point.

3. The problem I’m having:

I don’t know how to set HTTP server errors from a Caddyfile in Caddy v2.

Although, it appears you can do this via JSON config: Home · caddyserver/caddy Wiki · GitHub

4. Error messages and/or full log output:

N/A

5. What I already tried:

Tried errors and error directive. Also tried the same in the “global” configuration area. It doesn’t work.

6. Links to relevant resources:

N/A

My use case here is a custom 404 and 502 error page. Caddy by default returns the status code but no HTTP response at all.

1 Like

Thank you for trying v2!

I haven’t gotten around to adding error handling to the v2 Caddyfile yet. :slight_smile:

It or some equivalent will be available before the release candidate though!

OK, thanks, @matt! I’m excited to see what that will look like. I see you guys just added logging. Nice!

I wonder… would it be worthwhile to create a Caddyfile directive that maps 1-to-1 to JSON? That way, I can continue to use the Caddyfile to affect all parts of the v2 configuration…?

Anyway, I’m excited to see Caddy v2 become a thing! It appears to be gaining functionality pretty quickly.

That would defeat the purpose of the Caddyfile. If you want that level of control, just use JSON. :man_shrugging:

Give beta 7 a try! It doesn’t have the error handling in the Caddyfile yet but logging is finished.

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