在nginx环境下,直接用域名访问(首页)

①:

server {
listen 80;
server_name www.njm1.com;

location = / {    #=/规则可以直接访问域名。如:www.njm1.com。跳转到http://192.168.177.132:8080/njm1/test1/index_html;
proxy_pass http://192.168.177.132:8080/njm1/test1/index_html;
}

location ~ .*.(js|css.jpg.png)?$  #静态文件配置。必须要加,不然找不到你tomcat的静态文件。如下的proxy_pass http://192.168.177.132:8080;就是转到了tomcat,然后才能正常加载你的静态文件
{
proxy_pass http://192.168.177.132:8080;
}

#负载均衡
location /njm1/test1/ {
proxy_pass http://tomcats;
}
}

②:springmvc 如下(加了/njm1/test1/这个前缀)

html文件如下:(加了/njm1/test1/这个前缀)

原文地址:https://www.cnblogs.com/NJM-F/p/10076431.html