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

Maxim Dounin mdounin at mdounin.ru
Mon Jan 22 16:41:31 UTC 2018


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/


More information about the nginx mailing list