如果通过了多级反向代理的话,X-Forwarded-For的值并不止一个,而是一串IP值
This commit is contained in:
parent
bbbe83b737
commit
82819cb1e7
@ -20,6 +20,13 @@ public class IpUtils
|
||||
return "unknown";
|
||||
}
|
||||
String ip = request.getHeader("x-forwarded-for");
|
||||
if (StringUtils.isNotEmpty(ip) && !"unknown".equalsIgnoreCase(ip))
|
||||
{
|
||||
if (ip.indexOf(",") != -1)
|
||||
{
|
||||
ip = ip.split(",")[0];
|
||||
}
|
||||
}
|
||||
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))
|
||||
{
|
||||
ip = request.getHeader("Proxy-Client-IP");
|
||||
|
Loading…
x
Reference in New Issue
Block a user