場景 nginx 轉發端口 路由器二次轉發了,端口不同 (shiro 或者其餘一些權限控制架構會自動跳轉,致使的端口不對。)html
proxy_set_header Host $host:$proxy_port; nginx
這個$proxy_port 寫死 服務器
nigix作反向代理 cookie
注意 :$proxy_port 與 :$server_port 區別架構
$server_port :nigix監聽的端口代理
$proxy_port : 服務器真正訪問的端口server
server {htm
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; }