Welcome! Log In Create A New Profile

Advanced

Re: Possible bug with "proxy_intercept_errors on; " + "error_page 301 302"?

Maxim Dounin
June 30, 2023 08:46PM
Hello!

On Fri, Jun 30, 2023 at 01:24:18PM -0300, Fabiano Furtado Pessoa Coelho wrote:

> Hello Maxim...
>
> On Thu, Jun 29, 2023 at 7:00 PM Maxim Dounin <mdounin@mdounin.ru> wrote:
> >
> > Hello!
> >
> > On Thu, Jun 29, 2023 at 04:29:39PM -0300, Fabiano Furtado Pessoa Coelho wrote:
> >
> > > Hi...
> ...
> > > "proxy_intercept_errors on;"?
> >
> > The "proxy_intercept_errors" handling does not copy any response
> > headers from the original response (the only exception is
> > WWW-Authenticate for 403 responses).
> >
> > If you want nginx to copy some headers, consider doing it yourself
> > with the $upstream_http_* variables and the add_header directive.
> > Something like this should work:
> >
> > location /30x.html {
> > add_header Location $upstream_http_location;
> > ...
> > }
> >
> > Note though that you'll have to manually rewrite location if
> > needed (as proxy_redirect handling won't be used).
>
> Your approach worked fine for me! Thanks for the help.
>
> Horever, without this "add_header" modification and with
> "proxy_intercept_errors on;", I've two situations:
> * without "error_page 301 302 /30x.html;" directive configured: I
> receive the HTTP "location" header from my NGINX;
> * with "error_page 301 302 /30x.html;" directive configured: I don't
> receive the HTTP "location" header from my NGINX;
>
> If "proxy_intercept_errors" handling does not copy any response
> headers from the original response, why is this HTTP "location" header
> present with "error_page 301 302 /30x.html;" directive configured in
> my system?
>
> I really don't understand why it happens.

The "proxy_intercept_errors" directive only works for error
responses for which you have an error_page explicitly configured.
That is:

- If you don't have an error_page configured for the particular
response code, nginx returns the original response as obtained
from the upstream server, with all the response headers, much like
it does with "proxy_intercept_errors off;".

- If you do have an error_page configured, nginx instead
intercepts the error as per "proxy_intercept_errors on;", and
returns the error page to the client. This response does not contain
headers from the original response.

This seems to be exactly what you are seeing (assuming "with" in
your final question is a typo, and you mean "without" instead).
Hope this helps.

--
Maxim Dounin
http://mdounin.ru/
_______________________________________________
nginx mailing list
nginx@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Possible bug with "proxy_intercept_errors on; " + "error_page 301 302"?

Fabiano Furtado Pessoa Coelho June 29, 2023 03:30PM

Re: Possible bug with "proxy_intercept_errors on; " + "error_page 301 302"?

Maxim Dounin June 29, 2023 06:02PM

Re: Possible bug with "proxy_intercept_errors on; " + "error_page 301 302"?

Fabiano Furtado Pessoa Coelho June 29, 2023 06:12PM

Re: Possible bug with "proxy_intercept_errors on; " + "error_page 301 302"?

Fabiano Furtado Pessoa Coelho June 30, 2023 12:26PM

Re: Possible bug with "proxy_intercept_errors on; " + "error_page 301 302"?

Maxim Dounin June 30, 2023 08:46PM

Re: Possible bug with "proxy_intercept_errors on; " + "error_page 301 302"?

Fabiano Furtado Pessoa Coelho June 30, 2023 09:16PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 310
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