request.getHeader("x-forwarded-for");
出现多个ip且用逗号分隔: 210.21.71.88, 119.23.123.88
有人说使用最后一个ip就是最原始的ip?
请看维基百科:https://en.wikipedia.org/wiki/X-Forwarded-For
The general format of the field is:
- X-Forwarded-For: client, proxy1, proxy2[3]
where the value is a comma+space separated list of IP addresses, the left-most being the original client, and each successive proxy that passed the request adding the IP address where it received the request from. In this example, the request passed through proxy1, proxy2, and then proxy3 (not shown in the header). proxy3 appears as remote address of the request.
结论:ip经过代理服务器,会出现上述情况,取第一个才是真实IP
cnblogs.com/tomcatandjerry