I have two identical web servers behind an nginx reverse proxy. Both web servers normally share the load but during redeployment I need to take one out of rotation. I want to control this using the presence or absence of files.
This way works but it is not symmetrical (file for node1 but not node2) and it requires these repeated location sections and repeated definitions of upstreams. Is there a cleaner way?
upstream web-both {
server web1-stage:8080 ;
server web2-stage:8080 ;
}
location / {
try_files /both.html @node1 ;
proxy_pass http://web-both;
}
location @node1 {
try_files /node.html @node2 ;
proxy_pass http://web1-stage:8080;
}
location @node2 {
proxy_pass http://web2-stage:8080;
}