Multihop 502s

Hello all,

I’ve been trying to get Nginx to do multiple hops on error page
failovers. Like a cache miss on memcache (404) followed by a bad
gateway on the main server ending up at a fallback server. Here’s a
simplified example:

location / {
memcached_pass 1.2.3.4:11211;
error_page 404 502 = @main;
}

location @main {
error_page 502 = @fallback;

proxy_pass http://main_server;
break;

}

location @fallback {
proxy_pass http://fallback_server;
break;
}

However, the second 502 doesn’t get triggered, it just shows the
standard Nginx 502 page. It works as expected when the first hop
(memcache) is removed.

Is a multi-hop 502 possible?

Adam

On Mon, May 12, 2008 at 10:03:55PM -0700, Adam W. wrote:

location @main {
error_page 502 = @fallback;

proxy_pass http://main_server;
break;
  • break;
    
  • recursive_error_pages  on;
    

}

location @fallback {
proxy_pass http://fallback_server;
break;

  • break;
    

}

However, the second 502 doesn’t get triggered, it just shows the
standard Nginx 502 page. It works as expected when the first hop
(memcache) is removed.

Is a multi-hop 502 possible?

Use “recursive_error_pages on”.
Also "break"s are useless here and only waste CPU cycles.

On Mon, May 12, 2008 at 10:21 PM, Igor S. [email protected] wrote:

Use “recursive_error_pages on”.

Excellent! That did the trick.

Adam

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs