①:
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/這個前綴)