A configuração de trabalho:
geo $upstream {
default backend-1;
192.168.0.150 backend-1;
192.168.0.250 backend-2;
}
upstream backend-1 {
server 192.168.0.101:8080;
}
upstream backend-2 {
server 192.168.0.102:8080;
}
server {
listen 80;
location / {
proxy_pass http://$upstream;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}