404 fallback only hitting 2/3 upstream sets

helliax nginx-forum at nginx.us
Tue Aug 7 16:55:26 UTC 2012


I currently have a setup where I have 3 upstream sets (directives?), and
it will fallback in a chain. So if it gets a 404 from setA, it'll go to
setB. If setB also has a 404, then setC. The config is:

upstream setA {
	server ipA:port
}

upstream setB {
	server ipB:port
}
	
upstream setC {
	server ipC:port
}
	
	
	
    server {
        listen       80;
        server_name  localhost;
		
				
		  #SetAHandler
			location /
			{
				access_log  logs/access.log  main;
				
				error_page 404 502 503 504 = @SetBHandler;
				proxy_intercept_errors on;
				proxy_pass http://setA; 
				proxy_set_header Host $host;
				proxy_connect_timeout 60s;
				proxy_next_upstream error timeout http_500 http_502 http_503
http_504 http_404;
				
			#	proxy_cache nginx_cache;
			#	proxy_cache_valid  200 304 12h;
			#	expires      1d; 
				
			#	break;
			}


			location @SetBHandler
			{
				access_log  logs/access.log  main;
				proxy_intercept_errors on;
				
				error_page 404 502 503 504 = @SetCHandler;
				proxy_pass http://setB;
				proxy_set_header Host $host;
				proxy_connect_timeout 60s;
				proxy_next_upstream error timeout http_500 http_502 http_503
http_504 http_404;
				
				
			#	proxy_cache nginx_cache;
			#	proxy_cache_valid  200 304 12h;
			#	expires      1d; 
				
			#	break;
			}
			
			location @SetCHandler
			{
				access_log  logs/access.log  main;
				proxy_pass http://setC;
				proxy_set_header Host $host;
				proxy_connect_timeout 60s;
				proxy_next_upstream error timeout http_500 http_502 http_503
http_504 http_404;
				#Last proxy, return whatever it gives
				proxy_intercept_errors off;
				
			#	proxy_cache nginx_cache;
			#	proxy_cache_valid  200 304 12h;
			#	expires      1d; 
				
			#	break;
			}

The problem is, it only seems to check setA and setB, and bypasses setC
completely. I tested it by putting a file on the third IP in setC that
wasn't in setA or setB. Whenever I hit Nginx, it always returns 404,
when the expected behavior is for it to return the file at ipC.

 I have it logging th $upstream_addr, and everytime it 404s, the logs
always show:

<ipA> : <ipB>

Is there some directive from the HttpProxyModule that limits it to 2 by
default?

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



More information about the nginx mailing list