Nginx jumps to the specified project name

The application deployed by tomcat usually needs to be accessed by adding the project name, such as www.test.com/app/index, nginx needs to jump to the app level to open the desired page, you can use the following configuration:

#exact match
location = / {
    ……
    proxy_pass http://ip:port/app/;
}
location / {
    ……
    proxy_pass http://ip:port;
}

Need to pay attention to the difference between / after ip:port/app/, add / Omit the app, and directly display the corresponding file when accessing, otherwise it is the full path:
if you do not add / access http://192.168.10.100:9080/app/index.html , it will be displayed as http://192.168.10.100:9080/app /index.html
add/visit http://192.168.10.100:9080/app/index.html to display as http://192.168.10.100:9080/index.html

Guess you like

Origin blog.51cto.com/hunt1574/2605768