nginx-1.1.12

Maxim Dounin mdounin at mdounin.ru
Tue Dec 27 17:11:33 UTC 2011


Hello!

On Tue, Dec 27, 2011 at 06:09:50PM +0200, Boyko Yordanov wrote:

> nginx 1.1.12 behaves differently compared to nginx 1.1.11 on my 
> setup which I'll try to explain below.

[...]

> While my configs may not be optimized or may even be wrong, they 
> were interpreted differently by every nginx version other than 
> 1.1.12. Not sure if this is something I have to fix by changing 
> my configs?

(cc'd back to list)

Ok, so basically your config (simplified) is as follows:

    location / {
        index index.php;
    }

    location ~ \.php$ {
        proxy_pass http://backend;
    }

With 1.1.12 proxy_pass without URI component always uses modified 
URI after internal redirects, and as a result "/index.php" request 
is passed to upstream instead of "/" previously (as index module 
does an internal redirection, see [1]).

Apparently your backend doesn't like this and returns 302 in an 
attempt to normalize the URI.

Quick fix is to use something like

    location ~ \.php$ {
        proxy_pass http://backend$request_uri;
    }

to ensure original request uri is passed to upstream.  
Alternatively, you may use something like

    location ~ (\.php|/)$ {
        proxy_pass http://backend;
    }

[1] http://www.nginx.org/en/docs/http/request_processing.html#simple_php_site_configuration

Maxim Dounin



More information about the nginx mailing list