nginx proxy tomcat get real user IP

nginx proxy tomcat get real user IP

Disclaimer: This article is a blogger original article, follow the  CC 4.0 BY-SA  copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/buyaore_wo/article/details/69787681
1.nginx provided the location header, such as
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 configuration (the server.xml) was added RemoteIpValve configuration, such as
<Valve
className="org.apache.catalina.valves.RemoteIpValve"
httpServerPort="8088"
httpsServerPort="8443"
remoteIpHeader="x-forwarded-for"
proxiesHeader="x-forwarded-by"
protocolHeader="x-forwarded-proto"
/>

Guess you like

Origin www.cnblogs.com/think90/p/11454985.html