nginx反向代理有关端口的问题

今天在做nginx反向代理的时候,出现了一个问题:我们外网访问端口设置的是8088,但是因为外网访问默认端口是80,所以当页面发生重定向的时候,会出现页面访问不到的问题,、

尝试很多办法之后,终于得到了解决,特意分享出来,希望可以帮到有需要的朋友。

server {
        listen       内网端口;     
        server_name  域名a;  

        if ( $content_type ~ xwork2 ){
                return 403;
        }

        if ( $content_type ~ struts2 ){
                return 403;
        }

    client_header_buffer_size    100m;
    client_max_body_size        500m;
    client_body_buffer_size        100m;

        location / {
        index index.jsp index.do index.html index.htm;
                proxy_pass              访问的内网地址;  
                proxy_set_header        X-Real-IP $remote_addr;
                proxy_set_header        X-Forwarded-For $remote_addr;
                proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header        Host $host;
                #set_real_ip_from       0.0.0.0/24;
                #real_ip_header         X-Real-IP;
                proxy_headers_hash_max_size 51200;
                proxy_headers_hash_bucket_size 6400;
                proxy_redirect     a 
                                   a:8088;
        }
    
    location /web-console/ {}
    location /jmx-console/ {}
    location /invoker/ {}
}

这里需要配置一下proxy_redirect当上游服务器返回的响应是重定向或刷新请求(如HTTP响应码是301或者302)时,proxy_redirect可以重设HTTP头部的location或refresh字段

 

更多资料可以参考:http://blog.51cto.com/blief/1739178

 

转载于:https://www.cnblogs.com/xiaoQ0725/p/8548475.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值