Nginx as a Load Balancer
Posted: October 22, 2011 Filed under: System Administration Leave a comment »It is very basic setup of Nginx as a load balancer. I have two Apache servers (web1.meapay.com & web2.meapay.com). Ngnix will act as a load balancer in front of these two servers
I have done it on Debian squeeze. So first we have to install nginx package
#apt-get install nginx
Edit the nginx configuration file. Before editing, I have copied the original nginx conf file as default.orig
#cd /etc/nginx/sites-available/
#/etc/nginx/sites-available# cp default default.orig
#vi /etc/nginx/sites-available/default
upstream mysite {
server web1.meapay.com;
server web2.meapay.com;
}
server {
server_name http://www.meapay.com:80;
#listen [::]:80 default ipv6only=on; ## listen for ipv6
access_log /var/log/nginx/access.log;
location / {
proxy_pass http://mysite;
proxy_set_header Host $host;
}
}
#/etc/init.d/nginx restart
Its done.
Have FUN
Reference:
http://mickeyben.com/blog/2009/12/30/using-nginx-as-a-load-balancer/