业务场景
1.服务 1 通过方向代理 “域名/服务 1” 映射到 “服务器:10091/服务 1”——可以访问。
2.服务 2 通过反向代理 “域名/服务 2” 映射到 “服务器:10092/服务 2”——不可访问。
3.服务 3 通过反向代理 “域名/服务 3” 映射到 “服务器/10093/服务 3”——不可访问。
服务器上项目使用的 tomcat。
#proxy-start/服务名称
location ~* \.(php|jsp|cgi|asp|aspx)$
{
proxy_pass http://ip地址:端口号;
proxy_set_header host $host;
proxy_set_header x-real-ip $remote_addr;
proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for;
proxy_set_header remote-host $remote_addr;
}
location /服务名称
{
proxy_pass http://ip地址:端口号;
proxy_set_header host $host;
proxy_set_header x-real-ip $remote_addr;
proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for;
proxy_set_header remote-host $remote_addr;
add_header x-cache $upstream_cache_status;
#set nginx cache
add_header cache-control no-cache;
expires 12h;
}
#proxy-end/服务名称
这三个服务,不同的就只有 location 和端口。为什么其它 2 个就不能访问呢?
是 nginx 配置有问题,还是服务器有问题呢?