1.Background
Multiple projects, same IP, different port deployment access.
1.1 Requirements:
- Deploy a PC project, access address: http://192.168.31.1:8085/project name
- Deploy a dist project, access address: http://192.168.31.1:8086/project name
- Note: The above are just examples!
1.2 Personal experience
I have no such experience before, and I have not found any information on integration, so I will record it together~
2.Tomcat
2.1 Download address
The lower version or the latest version is not recommended. The latest version may be unstable. Download address: link
2.2 Modify webapps
This modification order is not fixed, but I am used to configuring and modifying it this way. You can do whatever you want. In order to distinguish it, I will copywebappsTwo numbers are added for distinction.
2.2.1 webapps1&webapps2
webapps1:
webapps2:
2.2.2 Tomcat->conf configuration file
There is a conf configuration file in the Tomcat installation directory, open it. existconfIn the directory, there is acatalina.policyMake a copy of the configuration file and differentiate it yourself. I use 1 and 2 to differentiate. (You don’t need to open this file, just make a copy)
2.2.3 serve.xml configuration file
Copy the service and modify it.This IP is the same~, just the port is different!
2.2.4 Start Tomcat server
Tomcat installation directory–>bin–>startup.bat, or use the command to start in the command window.
Complete startup
2.2.5 Access deployment: 8085
Access the address you configured in the browser address bar (expected result: access failed):http://xxx.xxx.xxx.xxx:8085/pc
Access the address you configured in the browser address bar (expected result: access successful):http://xxx.xxx.xxx.xxx:8085/dist
2.2.6 Access deployment: 8086
Access the address you configured in the browser address bar (expected result: access failed):http://xxx.xxx.xxx.xxx:8086/dist
Access the address you configured in the browser address bar (expected result: access successful):http://xxx.xxx.xxx.xxx:8086/pc
-------------------------------------------------- -----------------------Divider line-------------------------- -------------------------------------------------- --------------------------
3. Nginx
3.1 Download and decompress Nginx
Official website address: link
Try to download the stable version!
3.2 Unzip
3.3 Copy html
3.4 Put in the packaged project file
Project file in html:
Project file in html2:
3.5 Modify nginx.conf configuration
Installation directory–>conf–>nginx.conf
3.6 Start Nginx
Startup: Use start nginx in the command window or use the exe in the installation directory to start the program. Since my command window does not show that the startup is successful, we check whether the startup is successful in the resource management, as follows:Started successfully
3.7 Access port 80
Under normal configuration, port 80 can only access: dist project
Access address: localhost:80/distAccess
address: localhost:80/pcpc
3.8 Access port 9090
Under normal configuration, port 9090 can only access: pcpc project
Access address: localhost:9090/pcpc
Access address: localhost:9090/dist
4. Summary
The configuration of Tomcat and Nginx with the same host address and different ports is complete. If there are any problems or better methods, please leave comments~~~~~~