caddy: Custom error page when upstream no available
Hey!
I was able to configure a custom error page when upstream generates an error (say, 500 “Internal Server Error”). But it seems not possible to send a custom page, like 502.html when upstream is not available. I have found old discussion on community forum saying that it’s a limitation of current version. But maybe anything changed since that? Is it documented somewhere? Please advice.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 1
- Comments: 17 (10 by maintainers)
Really?
Firefox:
Maybe it’s a question on how docs are structured. I was looking at this because I thought it’s more relevant: https://caddyserver.com/docs/caddyfile/directives/reverse_proxy You can press
Ctrl-Fand look where it mentionserror. Actually that’s where my issue started from.Next I found this: https://caddy.community/t/caddy1-proxy-errors-page/6559/6
Which basically remained unanswered and is linked to the issue: https://github.com/caddyserver/caddy/issues/1447, and it’s not clear whether it’s solved or not and what should I do.
Showing error page when upstream not available is very basic thing and should be pretty simple to my understanding.
@inliquid I appreciate the effort you took to search the forum.
I just want to point out… did you notice that the docs page Francis linked to has an example (the very first one, in fact) that does exactly what you are asking? If it’s not what you’re asking, then we need you to fill out the help template on the forum because clearly we need more information to understand your question:
(No upstream available is 503 btw. You can use a matcher – also exhibited in the examples on that page – to limit to just that status code if you want.)
It’s more a question not about returning code, but how does
caddytreat this case. In my view this is “no upstreams available” because, that’s what happening on the ground - single configured backend is dead. As for codes, like I said I wouldn’t use 503 in my app because it mixes with handler timeouts so I would probably configure it like this:Not sure but should work?
I haven’t configured any healthchecking, there is single reverse_proxy directive and that’s basically it:
Before raising an issue I always google and look at docs, forums, whatsoever. In this particular case I looked at
caddy.communityusing both discourse search engine and googled withsite:caddy.community <blabla>. I don’t have time to fill-in complete experience report just to answer if it’s supported or not, and I don’t want to share sensitive data which may compromise my project. As I said I found info that feature is not supported. At this momentcaddyis basically an experiment and I still evaluating if we go for it or no. Mostly because I code in Go for years already and I feel a sympathy. But there are plenty of well-suited alternatives for every single “stupid” case with tons of examples, if documentation or support is a problem.