prevent nginx from translate 303 responses (see other) to 302 (temporary redirect)

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

prevent nginx from translate 303 responses (see other) to 302 (temporary redirect)

mdm100
Hi,

I have an apache webserver in front of which I put my nginx 1.12.2 that is
running with a basic proxy_pass configuration. I have done this a million
times, even with more complex cofigurations.

Everything works perfectly except one thing I recently noticed:
the login phase consists of a POST request with the url-encoded credentials
in the body. In case of successful authentication, the webserver returns a
303 (See Other) to the user's home. What's worng is that when I authenticate
through nginx the POST requests gets back a 302 instead of a 303.
Despite this not being a problem when using a common browser, this becomes a
blocking issue when using a command line software suite that mandatorily
expects a 303.

I have already searched the documentation, but I got nothing about such
behaviour.
Any idea on how I can prevent nginx from "translating" that 303 into a 302?

Thanks in advance for any hint.
PL

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,278217,278217#msg-278217

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: prevent nginx from translate 303 responses (see other) to 302 (temporary redirect)

Maxim Dounin
Hello!

On Mon, Jan 22, 2018 at 09:34:40AM -0500, plrunner wrote:

> I have an apache webserver in front of which I put my nginx 1.12.2 that is
> running with a basic proxy_pass configuration. I have done this a million
> times, even with more complex cofigurations.
>
> Everything works perfectly except one thing I recently noticed:
> the login phase consists of a POST request with the url-encoded credentials
> in the body. In case of successful authentication, the webserver returns a
> 303 (See Other) to the user's home. What's worng is that when I authenticate
> through nginx the POST requests gets back a 302 instead of a 303.
> Despite this not being a problem when using a common browser, this becomes a
> blocking issue when using a command line software suite that mandatorily
> expects a 303.
>
> I have already searched the documentation, but I got nothing about such
> behaviour.
> Any idea on how I can prevent nginx from "translating" that 303 into a 302?

There is nothing in nginx itself what can "translate" 303 to 302.  
It might be something conditional in your webserver though, and
proxying through nginx triggers different code path which returns
302 instead of 303.

In particular, I would recommend to check if

    proxy_http_version 1.1;

helps.  The default is 1.0, and your webserver might think that it
is not appropriate to return 303 to HTTP/1.0 clients.  See
http://nginx.org/r/proxy_http_version for details.

--
Maxim Dounin
http://mdounin.ru/
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: prevent nginx from translate 303 responses (see other) to 302 (temporary redirect)

mdm100
Great.

proxy_http_version 1.1;

did the trick. Thank you.


PL

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,278217,278223#msg-278223

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx