方法一:
1、配置Tomcat server.xml 的 Engine 模块开始的地方配置一个 Valve:
remoteIpHeader="X-Forwarded-For"
protocolHeader="X-Forwarded-Proto"
portHeader="x-forwarded-port"
proxiesHeader="x-forwarded-by"
protocolHeaderHttpsValue="https"/>
2、配置nginx,添加配置
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
方法二:
1、在jsp页面中,添加下面的meta头就可以了