Let's say you have 2 web servers. Both has NginX installed. You want to load balance the traffic between them. How do you do that in nginx.conf?
Server1:
http {
upstream myproject {
ip_hash;
server 127.0.0.1:8000;
server 10.0.0.2:8000;
}
server {
listen 80;
server_name www.domain.com;
location / {
proxy_pass http://myproject;
}
}
}
Server2:
http {
upstream myproject {
ip_hash;
server 127.0.0.1:8000;
server 10.0.0.1:8000;
}
server {
listen 80;
server_name www.domain.com;
location / {
proxy_pass http://myproject;
}
}
}
Should this work or is it a complete failure?
0 Answers