nginx根据url路径跳转不同的tomcat

根据location的url匹配进行配置:

1.在server上面配置如下:

upstream tomcat1{
    server 59.110.152.54:8082;
}
upstream tomcat2{
    server 59.110.152.54;
}

2.在server中添加如下:

location /hrms {
    proxy_pass http://tomcat1;
}
location /wxapi {
    proxy_pass http://tomcat2;
}

当链接是http://ip:port/hrms 时,转发给tomcat1
当链接是http://ip:port/wxapi 时,转发给tomcat2

详细配置参见下面文章:
https://www.cnblogs.com/coder-yoyo/p/6346595.html


原文出处:/show_1EF28Bd0b6jH.html