Welcome! Log In Create A New Profile

Advanced

Re: Static or dynamic content

Francis Daly
October 20, 2016 12:26PM
On Thu, Oct 20, 2016 at 09:19:29AM +0000, Jens Dueholm Christensen wrote:
> On Tuesday, October 18, 2016 08:28 AM Francis Daly wrote,

Hi there,

> > what output do you get when you use the test config in the earlier mail?
>
> Alas I did not try that config yet, but I would assume that my tests would show exactly the same as yours - should I try or is it purely academic?

Academic now, I think.

> If upstream returns 503 or 404 I would like to have the contents of the error_page for 404 or 503 returned to the client regardless of the HTTP request method used.

> > Possibly in your case you could convert the POST to a GET by using
> > proxy_method and proxy_pass within your error_page location.

> How would you suggest I could use proxy_method and proxy_pass within the @error_503 location?
> I'm comming up short on how to do that without beginning to resend a POST request as a GET request to upstream - a new request that could now potentially succeed (since a haproxy backend server could become available between the POST failed and the request is retried as a GET)?

I was imagining doing a proxy_pass to nginx, not to upstream, for the
503 errors. So dealing with upstream is not a concern.

However, I've tried testing this now, and it all seems to work happily
if you omit the @named location for error_page.

I add "internal" below, to avoid having the url be directly
externally-accessible.

Does this do what you want it to do?

server {
listen 8080;
error_page 503 /errors/503.html;
location / {
root html;
try_files /offline.html @xact;
}
location @xact {
# this server is "upstream"
proxy_pass http://127.0.0.1:8082;
proxy_intercept_errors on;
}
location = /errors/503.html {
internal;
# this serves $document_root/errors/503.html
}
}

For me, when "upstream" returns 503, I get back 503 with the content of
my /usr/local/nginx/html/errors/503.html, whether the initial request
was a GET or a POST.

So perhaps the previous awkwardness was due to the @named location and
the various rewrites.

If that does do what you want, then you can add something similar for 404,
I guess.

Cheers,

f
--
Francis Daly francis@daoine.org

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Static or dynamic content

Jens Dueholm Christensen September 28, 2016 07:04AM

Re: Static or dynamic content

Francis Daly September 29, 2016 06:04PM

RE: Static or dynamic content

Jens Dueholm Christensen September 30, 2016 05:58AM

Re: Static or dynamic content

Francis Daly September 30, 2016 06:56AM

RE: Static or dynamic content

Jens Dueholm Christensen October 15, 2016 08:20AM

Re: Static or dynamic content

Francis Daly October 18, 2016 02:30AM

RE: Static or dynamic content

Jens Dueholm Christensen October 20, 2016 05:22AM

Re: Static or dynamic content

Francis Daly October 20, 2016 12:26PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 258
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready