First download, install Tomcat.
Modify the Tomcat port and modify the Server.xml:
1. Modify the Tomcat port (default 8080)
<port= "8383" protocol= "http/1.1" connectiontimeout = "20000" redirectport= "8443"/>
2.shutdown Port (default 8005)
<port= "8006" shutdown= "shutdown"> < className = "Org.apache.catalina.startup.VersionLoggerListener"/>
3. Modify the AJP port (default 8009)
<!--- < port = "8019" protocol = "ajp/1.3" Redirectport = "8443" />
At the same time modify the boot two Tomcat, the port is 8383,8484 respectively.
Install Nginx, modify the nginx.conf file, configure Tomcat.
# Tomcat cluster configuration upstream tomcat_cluser{ server 127.0.0.1:8383 weight=1; Server 127.0.0.1:8484 weight=1; }
server { listen ; server_name 127.0.0.1; #charset Koi8-r; #access_log logs/host.access.log main; Location/{ Proxy_pass http://tomcat_cluser; root html; Index index.html index.htm; } Location ~ \.jsp$ { proxy_pass http://tomcat_cluser; } Location/schedule { proxy_pass http://tomcat_cluser; } Location ~. *\. (gif|jpg|jpeg|png|bmp|swf|apk|tar.gz) $ { expires 30d; } Location ~. *\. (JS|CSS)? $ { expires 12h; }}
Start Tomcat and start Nginx.
Visit: localhost, you can see.
[Tomcat] Tomcat+nginx Load balancer Configuration