Caddy1 proxy errors page

1. My Caddy version (caddy -version):

v1.0.3

2. How I run Caddy:

I just execute caddy with my CaddyFile on the same directory.

a. System environment:

OS, relevant versions, systemd? docker? etc.

Ubuntu, 64bit

b. Command:

caddy -conf CaddyFile

d. My complete Caddyfile:

mydomain.com {
        tls myemail@gmail.com
        proxy / http://localhost:8080 http://localhost:8081 {
                fail_timeout 1m
                try_duration 2s
        }
        errors {
                502 /home/website/maintenance/maintenance_502.html
        }
}

3. The problem I’m having:

I want to show that .html page when no proxies are online, currently when this happens I just get a page showing 502 error page, but not the .html page I made.

Error logging is enabled (I can see it on the terminal) but the page is not rendered.

Hi @Raggaer, welcome to the Caddy community.

As far as I know, this is dependent on who generates the 502 - Caddy, or the upstream.

Can you post the Caddy error logs you’re seeing?

The results from curl -IL http://localhost:8080 and curl -IL http://localhost:8081 might be useful as well.

True @Whitestrake , I guess was wrong then with my question.

I would like to show that .html page when both servers are offline (:8080 and :8081). Is that something I can achieve?

I wouldn’t say your question was wrong.

To clarify my post, whether the custom error page is displayed depends on whether Caddy generated the 502.

If the upstream server returned a 502 to Caddy, Caddy will faithfully pass that on to the client - it’s a valid response from upstream, so Caddy won’t “overwrite” that response with a custom error page.

@Whitestrake The server does not return 502 since the sever is offline. Trying to contact it with curl -IL http://localhost:8080 or curl -IL http://localhost:8081 gives me Failed to connect.

So the 502 comes directly from Caddy, I am guessing.

Hmm.

Juuuuust to double check before I send you over to the issues page to file a bug, can you just confirm for me the output of ls -a /home/website/maintenance/maintenance_502.html?

It does exist. I noticed this issue: Custom error pages for proxy backend errors not possible · Issue #1447 · caddyserver/caddy · GitHub might be related to my problem :frowning:

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