1. The effect:
Use Nginx reverse proxy, jump to different port services according to the access path, Nginx listening port is 9001
- Visit http://127.0.0.1:9001/bs-manager/ to jump directly to 127.0.0.1:8001
- Visit http://127.0.0.1:9001/bs-webapp/ to jump directly to 127.0.0.1:8002
2. Preparation
- Prepare two tomcat servers, one port 8001 and one port 8002.
- Edit the file using the command: /conf/server.xml file vim server.xml
- The revised version is as follows:
1. Modify the default port of the server from 8005-> 8091 by default
2. Modify the default port of http protocol, from the default 8080-> 8082
3. Modify the default port of the default ajp protocol from the default 8009-> 9001
- tomcat8.5 modify the port number at the start command bin directory ./startup.sh
- Start Tomcat on Linux, the result pops up: -bash: ./startup.sh: Permission denied prompt, solution
用命令chmod 修改一下bin目录下的.sh权限就可以了
chmod u+x *.sh
这里的u 这里指文件所有者,+x 添加可执行权限,*.sh表示所有的sh文件。
4. Test page: (Precondition: The server needs to open the firewall or the corresponding port number)
IP: 8001 pass, IP: 8002 pass ( Online server needs to wait about 5 minutes to pass )
Three, concrete arrangement
- Prepare test page ( link for preview )
- tomcat of tomcat8001, put it under the directory / webapp / bs-webapp, content: login template
- tomcat of tomcat8002, put it in the directory / webapp / bs-manager, content: vue project packaged by yourself
2. Modify the Nginx configuration
Modify the configuration file of nginx Add server {} in the http block to
modify the comments.
After successful modification
- Developed ports: nginx listening port: 9001, tomcat8001 port: 8001, tomcat8002 port: 8002.
- The test result test.wxw.plus represents your server IP
Summary: The location directive indicates that this directive is used to match URLs.
- The syntax is as follows:
- = : Before being used for uri without regular expression, the request string must be strictly matched with uri. If the match is successful, stop searching downward and process the request immediately.
- ~ : Used to indicate that uri contains regular expressions and is case sensitive.
- ~ * : Used to indicate that uri contains regular expressions and is not case sensitive.
- ^ ~ : Before being used for URIs without regular expressions, the Nginx server is required to find the location with the highest matching between the uri and the request string, and then use this location to process the request, instead of using the regular uri and request in the location block String matching.
Note: If uri contains a regular expression, it must have a ~ or ~ * mark.