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

Possibility to proxy to error page #753

Closed
stp-ip opened this issue Apr 14, 2016 · 14 comments
Closed

Possibility to proxy to error page #753

stp-ip opened this issue Apr 14, 2016 · 14 comments
Labels
feature ⚙️ New feature or request
Milestone

Comments

@stp-ip
Copy link

stp-ip commented Apr 14, 2016

Instead of just serving a static error page it might be great to provide a url, which then gets proxied to or as an easier implementation just fetches the error page and serves them.
Something along the lines of:

500 500_error.html <- serving static site
404 https://example.com/404.html <- page is fetched and delivered to the client

@mholt
Copy link
Member

mholt commented Apr 15, 2016

What's the use case for this?

@mholt mholt added the feature ⚙️ New feature or request label Apr 15, 2016
@stp-ip
Copy link
Author

stp-ip commented Apr 15, 2016

Handling errors on multiple projects/project sites in a single location. Could be an maintenance page or just a better overview page for all projects etc. The zentral location might be able to handle the error or redirect the user better than a local page.

But that was just an idea.

@warpr
Copy link

warpr commented Apr 21, 2016

I use something like this in nginx where if nginx cannot find a file to serve statically, the request is proxied to a backend application which does more advanced content negotiation than nginx can do to try and determine which file the client wanted, and redirect them to it.

(I found this issue as I was trying to rewrite that nginx config as a Caddyfile)

In nginx the config is something like:

location / {
    error_page 404 = @content_negotation;

    location @content_negotiation {
        proxy_pass http://127.0.0.1:3000;
    }
}

@k0nsl
Copy link

k0nsl commented Jun 29, 2016

Any progress on this? I was looking through the documentation and could not find any reference on how to intercept errors when using Caddy as a reverse proxy; I am needing this mostly for the 404s.

The equivalent working nginx configuration for this would look something like this:

        error_page 500 502 503 504 /custom_50x.html;
        location = /custom_50x.html {
                root /usr/share/nginx/k0nsl;
                internal;
        }
        error_page 404 403 /custom_40x.html;
        location = /custom_40x.html {
                root /usr/share/nginx/k0nsl;
                internal;
        }
        proxy_intercept_errors on;

Thanks in advance!

@mholt
Copy link
Member

mholt commented Jun 29, 2016

Not yet. Been busy with other things!

@k0nsl
Copy link

k0nsl commented Apr 29, 2017

I just returned to this issue because I found a strange situation where this type of functionality would be ideal. I understand that this is likely something just a very, very small user base of Caddy would need or use this ‘feature’...nonetheless, I am going to give it a bit of a bump so that it is noticed again :)

@francislavoie
Copy link
Member

I was actually talking to @mholt about this yesterday, i.e. custom error pages served from Caddy if the proxy returns a specific status code. I wouldn't mind this being implemented either!

The use-case was the Discourse forum was being upgraded, and it was throwing error 500 in the meantime. If this was implemented, we could have an maintenance page or something like that if the proxy returns errors.

@itsbhanusharma
Copy link

I was Planning on moving from nginx to caddy for the reverse Proxy of our discourse server. This remains the only part that is to be figured out. This issue has been here since 2016 So I just wanted to know if there had been any progress in this direction?

Kudos @mholt

@tobya
Copy link
Collaborator

tobya commented Jan 15, 2018

Thanks @itsbhanusharma it looks like this would be a good fit for the caddy project, but at the moment it isnt on a milestone so is not in active development. We are of course always happy to accept contributions. Your bump will keep it up there though.

@tufu9441
Copy link

Looking forward to see Caddy to implement this feature too, it is useful in quite a few occasions.

@nexitem
Copy link

nexitem commented Mar 26, 2019

Well is this possible now? I ran into this today cause I wanted to serve a better error page instead of the default one for my proxy's

@francislavoie
Copy link
Member

@nexitem my understanding is that there will be changes to error handling and logging in prep for 1.0, so it's definitely possible this will be covered soon. If you want something sooner, feel free to make a PR!

@nexitem
Copy link

nexitem commented Mar 27, 2019

@nexitem my understanding is that there will be changes to error handling and logging in prep for 1.0, so it's definitely possible this will be covered soon. If you want something sooner, feel free to make a PR!

Oh this is good enough for now :)

@mholt
Copy link
Member

mholt commented May 9, 2019

Error handling has been totally revamped in Caddy 2, so that this should be possible.

@mholt mholt closed this as completed May 9, 2019
@mholt mholt added this to the 2.0 milestone May 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature ⚙️ New feature or request
Projects
None yet
Development

No branches or pull requests

9 participants