I have 2 VPS servers with PHP applications that both use the same database ( on 3rd server). I want to have 4th server with just nginx as load balancer to try to "divide" the traffic in two.

My questions is - what is going to happen if nginx recieves a request, tries to forward it to one of the servers but the server does not respond. Is it going to try to send it to the second server or not ?

It is important for me not have a single lost request, so if Server1 fails, Server2 is going receive the same request immediately. Is this how nginx works ? If not, can I do it with nginx or I should try using another solution ?



You can set the proxy_next_upstream parameter to set the error conditions when nginx will retry a request on another upstream proxy server.

For example:

proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.