1. 程式人生 > >nginx轉發端口路由器再轉發

nginx轉發端口路由器再轉發

direct err -- 服務器 main .html 權限控制 shiro pass

場景 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;
}

nginx轉發端口路由器再轉發