【发布时间】:2020-06-11 01:33:31
【问题描述】:
您好,我在将 nginx 配置为代理服务器以将请求重定向到我的 tomcat 服务器时遇到问题。我有 3 台 tomcat 服务器在不同的机器和不同的端口上运行,就像这样
192.168.51.115:8115
192.168.51.120:8120
192.168.51.130:8130
现在我想配置 nginx 像这样依次将请求传递给我的三台服务器
www.example.com/app1
www.example.com/app2
www.example.com/app3
真实IP:123.123.123.123
这是我在 - site-enabled 下的配置
server {
listen 80;
server_name example.com www.example.com;
location /app1 {
proxy_pass "http://192.168.51.115:8115";
}
location /app2 {
proxy_pass "http://192.168.51.120:8120";
}
location /app3 {
proxy_pass http://192.168.51.130:8130;
}
}
注意:当我将位置指令放置在 / 上时,它可以工作,但不适用于 /*,如 app1、app2 或 app3
【问题讨论】:
标签: nginx tomcat reverse-proxy nginx-reverse-proxy