nginx代理 tomcat获得真实用户IP

nginx代理 tomcat获得真实用户IP

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/buyaore_wo/article/details/69787681
1.nginx的location中设置 header,如
location /ConfigService/{
proxy_read_timeout 90;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://www.qawe.info:8088/ConfigService/;
}
2.tomcat配置(server.xml)中添加RemoteIpValve配置,如
<Valve
className="org.apache.catalina.valves.RemoteIpValve"
httpServerPort="8088"
httpsServerPort="8443"
remoteIpHeader="x-forwarded-for"
proxiesHeader="x-forwarded-by"
protocolHeader="x-forwarded-proto"
/>
posted on 2019-09-03 19:21  曹明  阅读(353)  评论(0编辑  收藏  举报