Thursday, January 5, 2012

Nginx as a Load Balancer

Environments: 
There are three servers. One has been installed nginx (192.168.152.142, here). The other two servers (192.168.152.140, 192.168.152.143) have been install tomcat server (here).
Scenario:
The http request be submitted to nginx server, then we take nginx server as a load balancer to assign this request to one of tomcat servers equally.
Configuration Nginx (Windows)
1. Add the following paragraph content into nginx.conf (C:\nginx\conf\nginx.conf)

http {
upstream examples{
ip_hash;
server 192.168.152.140:8080;
server 192.168.152.143:8080;
}
       server {
         listen       80;
         server_name  localhost;
         location / { proxy_pass http://examples;
                       }
       }
}
2. restart your nginx. 

No comments:

Post a Comment