Is it possible to have nginx retry a second backend before returning a 502 to the client?
Would something like this work?
Front end:
# haproxy:85 => [a few app servers]:8000
# more specifically:
# haproxy => [nginx => unicorn (502 when busy)]
# Will this try a second app server when the first returns 502?
upstream haproxy {
server 127.0.0.1:85;
server 127.0.0.1:85 backup;
}
server {
listen 80;
proxy_pass http://haproxy;
proxy_next_upstream http_502;
}
Back end:
upstream unicorn {
server unix:/tmp/unicorn.sock fail_timeout=0;
}
server {
listen 8000;
proxy_pass http://unicorn;
}
Anyway, I'm just curious. This is actually probably pretty stupid because the retry could end up hitting the same overloaded server and would end up returning a 502 anyway...