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

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

你可能感兴趣的:(ip,java,tomcat,nginx)