nginx轉發端口路由器再轉發


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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM