http{
upstream /tomcatserver{
sticky name =srv_id;
#监听端口
server 127.0.0.1:8080;
server 127.0.0.1:8081;
}
server{
listen 80;
server_name 127.0.0.1 www.baidu.com;
location ~ ^/(css|js|html){
add_header Cache-Control no-store;
}
location =/index.html{
index index.html;
}
location /wkbtest{
try_files '' /index.html;
proxy_pass http://tomcatserver/wkbtest;
client_max_body_size 100m;
}
location /wkbtest2{
try_files '' /index.html;
proxy_pass http://tomcatserver/wkbtest2;
client_max_body_size 100m;
}
}
}
主要的配置就是:
配置之后访问到wkbtest工程的所有请求都会跳转到index.html页面上。