码迷,mamicode.com
首页 > 其他好文 > 详细

nginx转发端口路由器再转发

时间:2018-05-24 11:48:47      阅读:180      评论:0      收藏:0      [点我收藏+]

标签:导致   rect   err   serve   路由   har   charset   自动跳转   The   

场景 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转发端口路由器再转发

标签:导致   rect   err   serve   路由   har   charset   自动跳转   The   

原文地址:https://www.cnblogs.com/psy5choit/p/9081441.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!