Nginx+Tomcat无法正确获取的域名和ip地址

asoren

ngxin设置:

proxy_set_header Host $http_host;

代码片段如下:

server {
        listen       80;
        server_name  www.aso.ren;
        autoindex off;
        location / {
            root   /da/www/webapps;
            index  index.html index.jsp;
            proxy_pass       http://localhost:8080;

            proxy_redirect off;
            proxy_set_header  Host $http_host;
            proxy_set_header  X-Real-IP  $remote_addr;
            proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;
        }
}

备注:

proxy_set_header  Host                    $http_host;            # 将当前Host头域值填充成客户端地址
proxy_set_header  X-Forwarded-Server      $host;  
proxy_set_header  X-Forwarded-For         $proxy_add_x_forwarded_for;    # 代理路由信息,此处取ip有安全隐患
proxy_set_header  X-Forwarded-Proto       $scheme;                      # 真实用户访问协议
proxy_set_header  X-Real-IP               $remote_addr;                # 真实用户IP
阅读 4.1k

leifeng
java,ios,android,爬虫等相关内容更新
404 声望
14 粉丝
0 条评论
404 声望
14 粉丝
文章目录
宣传栏