Sunday, January 03, 2010

How to use Nginx to load balance a website

Have a look at http://mickeyben.com/2009/12/30/using-nginx-as-a-load-balancer.html to see how to use Nginx as a load balancer.

upstream  yoursite  {
server yoursite1.yoursite.com;
server yoursite2.yoursite.com;
}

server {
server_name www.yoursite.com;
location / {
proxy_pass http://yoursite;
}
}








The configuration is really simple, additionally you can use the ip_hash directive to forward all the request of the same client to the same server:









upstream  yoursite  {
ip_hash;
server yoursite1.yoursite.com;
server yoursite2.yoursite.com;
}



No comments: