Hi Chris,
Nginx is using a round robin algorithm to decide which host should get the request, since you are (probably) the only user tomcat 1 and tomcat 2 are getting each 50% of the trafic.
Now you want all trafic to go to tomcat 2 because tomcat 1 is down, and you can achieve this by telling Nginx to mark a server as down if it cannot reach it:
upstream backend {
#ip_hash;
server 10.10.10.120:8081 max_fails=3 fail_timeout=30s; # this has a jsp page say "tomcat 1"
server 10.10.10.120:8080 max_fails=3 fail_timeout=30s; # this has a jsp page say "tomcat 2"
}
also ip_hash is telling the Nginx to route all request form a single host to the same backend server.
More info you can find here: http://wiki.nginx.org/HttpUpstreamModule
Nginx is using a round robin algorithm to decide which host should get the request, since you are (probably) the only user tomcat 1 and tomcat 2 are getting each 50% of the trafic.
Now you want all trafic to go to tomcat 2 because tomcat 1 is down, and you can achieve this by telling Nginx to mark a server as down if it cannot reach it:
upstream backend {
#ip_hash;
server 10.10.10.120:8081 max_fails=3 fail_timeout=30s; # this has a jsp page say "tomcat 1"
server 10.10.10.120:8080 max_fails=3 fail_timeout=30s; # this has a jsp page say "tomcat 2"
}
also ip_hash is telling the Nginx to route all request form a single host to the same backend server.
More info you can find here: http://wiki.nginx.org/HttpUpstreamModule