I have a load balancer running HAProxy with two backend servers both running Nginx on to Unicorn.
If nginx goes down on one of these boxes HAProxy takes it out of the set and the service continues to operate.
If unicorn goes down nginx starts serving up 502 errors and HAProxy happily forwards them on to the client.
As I see it there are two possible solutions:
- Configure nginx not respond at all if it can't connect to unicorn. HAProxy will think its down and no longer send requests there.
- Configure haproxy to consider 502s as server down and not send any more requests to there.
Neither of which I can work out how to do