我正在运行nxinx反向代理。这是我的设置
nginx反向代理运行于
我有2个应用1开发和1个生产运行在不同的服务器上
后端1:8080 / app
后端2:8080 / app
我希望能够去
https://proxy.sub.domain.com/dev/app并转到backend2并显示网址https://proxy.sub.domain.com/dev/app
也去
https://proxy.sub.domain.com/app并转到backend1并显示网址https://proxy.sub.domain.com/app
由于某些原因/ dev /始终重定向到https://proxy.sub.domain.com/app
有人能指出我正确的方向吗?
配置
location /dev/app/ {
rewrite ^/dev/(.*)$ /$1 break;
proxy_pass http://192.168.1.21:8080/app/;
proxy_redirect http://192.168.1.21:8080/app $scheme://$http_host/dev/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 20d;
}
location /app {
proxy_pass http://192.168.1.20:8080/app;
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 X-Forwarded-Proto https;
}