Use Nginx and two Tomcats to achieve load balancing, and close the tomcat ports (8080 and 8090) in the firewall, and only open port 80 to the outside world. Nginx configuration is as follows:
upstream tomcatCluster {
Upstream listen 80;
server_name dev.xjj. cn
… use proxy.conf;
Distributed to two tomcats.
Requirements:
When one of the tomcats is upgraded, you need to directly access its page to test whether there are errors.
Requirement analysis:
The Tomcat port has been blocked by the firewall from external access and cannot be directly accessed through "http://
:8080/" or "http://:8090" /"Access a certain tomcat for testing. The solution can only be forwarded through Nginx.
Solution:
You can achieve direct access to a tomcat through Nginx rewrite combined with proxy_pass. The configuration and explanation are as follows, Add two location configurations in the Nginx location configuration:
#8080 port test page only- Location ~* /tomcat8080-/ {
write ^/tomcat8080-(.*) /$1 break;
using use using through use out through through ‐ ‐ out to to write /192.168.0.9:8080 ;}
#8090 port test page Special - Location ~/tomcat8090- & lt; project-name & gt;/{
include proxy.conf;
Rewrite ^/Tomcat809 0- (. *) / $1 break; Put the request URI http://dev. xjj.cn/tomcat8090-/*** Replace with http://dev.xjj.cn//***proxy_pass statement: Request http://dev .xjj.cn//*** is replaced by http://192.168.0.9:8090//***
In this way, through the combination of rewrite and proxy_pass statements, it is achieved Get precise access to a certain tomcat. -
The above introduces the method of accurately accessing tomcat after using multiple tomcats to achieve load balancing and the tomcat port is not open to the public, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.