id,summary,reporter,owner,description,type,status,priority,milestone,component,version,resolution,keywords,cc,uname,nginx_version 184,Unspecified behavior when going through multiple named locations,www.google.com/accounts/o8/id?id=AItOawnQxODTko53PmY0va90aNN76a_jMUVqVco,somebody,"I have complex configuration which demands multiple jumps between named locations to avoid config duplication. Config is like: error_page 404 /404.htm; location = / { rewrite ^ /showpage/; error_page 418 = @contcommon; recursive_error_pages on; return 418; } location @contcommon { #common steps for several locations if ( [some tests1] ) { return 403; } if ( [some tests2] ) { return 403; } if ( $request_method = POST ) { error_page 418 = @cgipass; #post requests go directly to cgi return 418; } recursive_error_pages on; error_page 418 = @cgicache; #get requests go through memcache check return 418; } location @cgicache { set $memcached_key ""$http_host$request_uri:blablabla""; error_page 404 502 504 = @cgipass; recursive_error_pages on; memcached_pass path/to/socket; } location @cgipass { #...some checks and rewrites like rewrite ^/([a-z]+)(?:/(.*))?$ /cgi-bin/$1.fcg/$2; proxy_pass ..... #pass to apache } root /my/root; location / { } Problem is that memcached_pass is never applied for ""GET /"", i.e. nginx goes to default location section and tries to open file ""/my/root/showpage/index.html"" and shows ""/404.htm"". Placing, e.g. ""return 405"", at the beginning of @cgipass gives error 405 as it must, but no content handler is executed whatever it was. I tried several which has content handlers like proxy_pass and stub_status. It looked like content_handler field of request is erased at some point. I looked through sources several times, trying to find such place, turned on debugging and carried out different experiments. After several hours I've found solution which overcomes the problem: put ""break"" inside @cgicache section. So it began to look like: location @cgicache { set $memcached_key ""$http_host$request_uri:blablabla""; break; #############that's it error_page 404 502 504 = @cgipass; recursive_error_pages on; memcached_pass path/to/socket; } Now memcached_pass began to work and @cgipass is called when no key found in memcache. BUT! One more strange thing. If memcached_pass is commented out request continues to work! But it shouldn't (it should show ""/404.html"" as it did without break). Error log says that attempt to read ""/my/root/showpage/index.html"" is happening and it returns 404 error, but for some unknown reason error_page from @cgicache still works (though location ""/"" is working at that point) and directs nginx to @cgipass location where final processing occurs. It seems that script code of rewrite module becomes broken at some point. I'm not sure that my solution is universal, but it worked in such config with ""GET /"" request. ",defect,closed,major,1.3.3,nginx-core,1.3.x,fixed,named locations error_page,,Linux 3.2.13 ,tested on 1.2.1 and 1.3.2