Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

httpcaddyfile: Add error directive for the existing handler #4034

Merged
merged 2 commits into from
Mar 12, 2021

Conversation

francislavoie
Copy link
Member

Closes #3782

Just adds Caddyfile support for the static error handler that already exists: https://caddyserver.com/docs/json/apps/http/servers/routes/handle/error/

Syntax:

error [<matcher>] <status>|<message> [<status>] {
    message <text>
}

mholt
mholt previously approved these changes Mar 2, 2021
Copy link
Member

@mholt mholt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM! I do have a question regarding the directive order but no answer or preference as to that.

caddyconfig/httpcaddyfile/directives.go Outdated Show resolved Hide resolved
@francislavoie francislavoie dismissed stale reviews from mholt and lilbee101920 via a07ab82 March 3, 2021 20:29
Copy link
Member

@mholt mholt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, cool, let's give this a try and see if it's useful!

@mholt mholt merged commit 0d7fe36 into caddyserver:master Mar 12, 2021
@francislavoie francislavoie deleted the error-directive branch March 12, 2021 20:39
@habibalamin
Copy link

This was one of the things keeping me on an older version of Caddy, so thank you for this.

@francislavoie
Copy link
Member Author

@habibalamin which version? This isn't something that existed in a previous version.

@habibalamin
Copy link

habibalamin commented Apr 10, 2021

Sorry, I was a bit unclear. There was a “rewrite hack” for the exact use case in the linked issue that you could do in v1 but not v2, and adding this directive gets me one step closer to letting me migrate to v2, i.e. this isn't something that existed in an older version, but it was something you could mimic with a workaround that's no longer allowed in v2 (which cleaned things up).

mholt pushed a commit to caddyserver/website that referenced this pull request Apr 16, 2021
Docs for the new directive in caddyserver/caddy#4034.

Also adding a bit in `handle_errors` mentioning that `reverse_proxy` doesn't trigger errors when a response has an "error" HTTP status; not sure how to word this clearly, cause `reverse_proxy` still can trigger errors if there's no upstream or whatever. We should probably add examples for that later, and augment this paragraph to mention `handle_response` once that's merged (caddyserver/caddy#4021)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

httpcaddyfile: respond with error page from handle_errors
4 participants