nginx反向代理出现404

今天配置nginx过程中出现一个问题,

用proxy_pass配置$host:port访问tomcat,反向代理没有问题,但是改成upstream的名字访问就是404

upstream tomcat1_server{
    server 192.168.195.128:8080;
}
upstream tomcat2_server{
    server 192.168.195.129:8080;
}

server {
    listen       80;
    server_name  www.jq.com;
    charset utf-8;

    location ^~ /tomcat1/{
        proxy_pass http://tomcat1_server;
    }
}

后来发现原来如果proxy_pass后面的名字后面加上/即可解决

upstream tomcat1_server{
    server 192.168.195.128:8080;
}
upstream tomcat2_server{
    server 192.168.195.129:8080;
}

server {
    listen       80;
    server_name  www.jq.com;
    charset utf-8;

    location ^~ /tomcat1/{
        proxy_pass http://tomcat1_server/;
    }
}

 

转载于:https://my.oschina.net/u/3067322/blog/1492771

你可能感兴趣的:(nginx反向代理出现404)