nginx automatic failover load balancing
Posted
by robinmag
on Server Fault
See other posts from Server Fault
or by robinmag
Published on 2010-05-12T07:41:03Z
Indexed on
2010/05/12
7:44 UTC
Read the original article
Hit count: 260
Hi,
I'm using nginx and NginxHttpUpstreamModule for loadbalancing. My config is very simple:
upstream lb {
server 127.0.0.1:8081;
server 127.0.0.1:8082;
}
server {
listen 89;
server_name localhost;
location / {
proxy_pass http://lb;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
But with this config, when one of 2 backend server is down, nginx still routes request to it and it results in timeout half of the time :(
Is there any solution to make nginx to automatically route the request to another server when it detects a downed server.
Thank you.
© Server Fault or respective owner