The location behaviour in 0.7 - bug or feature?

Georgi Hristozov georgi at
Fri Jul 11 00:54:31 MSD 2008

I'm happily using nginx 0.6 as a proxy to my Apache server. Nginx is 
serving the static content and Apache is doing the complicated work. 
I've been using  rules like this to proxy the requests:

location ~ \.php$ {
	proxy_pass   http://ip:port;
location ~ /$ {
	proxy_pass   http://ip:port;

Obviously the first one redirects all requests to php scripts to the 
Apache daemon. The second one is in order to show the fancy Apache 
directory listings. Additionally, some directories should not be listed 
and it is defined in their respective .htaccess files, so I can't serve 
requests ending with / using nginx. The second "location" block 
guarantees that the .htaccess files will be respected (served by 
Apache), at least when directory listings are generated.
This configuration worked ok for months until I tried to upgrade to the 
dev branch of nginx. I tried not to touch my config files. One of my 
virtual hosts uses fancy indexing for showing its structure and when I 
tried I was surprised to get a 403 error from nginx. 
The request to / wasn't passed to Apache at all. The 0.6 version had 
done it until that moment. The request to hit 
Apache and I got the desired fancy index, it seemed that the problem is 
only with /. I added the following lines to all of my vhosts in the 
nginx.conf file:

location = / {
	proxy_pass   http://ip:port;

And now 0.7 works like a charm.
Now the question - shouldn't "location ~ /$" match / aswell? And why it 
matches it in 0.6, but doesn't match it in the 0.7 branch? I traced it 
back to 0.7.0, it seems that the whole branch doesn't work with this 
"old" config from 0.6. Is it a bug or feature? :)

Thanks in advance!

Georgi Hristozov

More information about the nginx mailing list