Example 1
Achieve results: www.test.com entered in the browser, tomcat jump to the main page.
Under Mac hosts here:
/etc/hosts
Configure ip domain name mapping:
Nginx modify configuration files nginx.conf:
To listen on port 80, to configure a forwarding path, it is forwarded to the machine tomcat.
Reload Nginx:
sudo nginx -s reload
Start tomcat, in the browser to access www.test.com:
Automatically jump to the tomcat welcome page:
Example 2
To achieve the effect: Use Nginx reverse proxy, jump to a different service port in the path of access, Nginx listening port is 9001.
访问http://localhost:9001/edu/ 跳转到127.0.0.1:8080
访问http://localhost:9001/vod/ 跳转到127.0.0.1:8082
Prepare two tomcat:
- tomcat9 port 8082
- tomcat8 port 8080
Html prepare two documents:
Tomcat9 in the first place:
webapps / EDU / a.html:
In the second tomcat8:
the webapps / VOD / a.html:
Nginx modify configuration files nginx.conf:
Nginx and started two tomcat:
Browser enter: localhost: 9001 / edu / a.html
Browser enter: localhost: 9001 / vod / a.html