场景 nginx 转发端口 路由器二次转发了, 端口不一样 (shiro 或者其他一些权限控制架构会自动跳转, 导致的端口不对.)
proxy_set_header Host $host:$proxy_port;
这个 $proxy_port 写死
nigix 做反向代理
注意 :$proxy_port 与 :$server_port 区别
$server_port :nigix 监听的端口
$proxy_port : 服务器真正访问的端口
- server {
- listen 8888;
- server_name 192.168.1.114;
- #charset koi8-r;
- #access_log logs/host.access.log main;
- location /a {
- proxy_pass http://127.0.0.1:8080;
- proxy_set_header Host $host:$proxy_port;
- }
- location /b {
- proxy_pass http://192.168.1.102:8080/b;
- proxy_cookie_path /a /b;
- }
- #error_page 404 /404.html;
- # redirect server error pages to the static page /50x.html
- #
- error_page 500 502 503 504 /50x.html;
- location = /50x.html {
- root html;
- }
- -----------------------------------------------------------------------------------------------------------------
- server {
- listen 8888;
- server_name 192.168.1.114;
- #charset koi8-r;
- #access_log logs/host.access.log main;
- location /a {
- proxy_pass http://127.0.0.1:8080;
- proxy_set_header Host $host:$server_port;
- }
- location /b {
- proxy_pass http://192.168.1.102:8080/b;
- proxy_cookie_path /a /b;
- }
- #error_page 404 /404.html;
- # redirect server error pages to the static page /50x.html
- #
- error_page 500 502 503 504 /50x.html;
- location = /50x.html {
- root html;
- }
来源: http://www.bubuko.com/infodetail-2614967.html