+ -
当前位置:首页 → 问答吧 → linux下 怎么配置apache 才能获取到真实的客户端IP

linux下 怎么配置apache 才能获取到真实的客户端IP

时间:2011-10-18

来源:互联网

String ip = request.getHeader("X-Forwarded-For");

if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("Proxy-Client-IP");
}

if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("WL-Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getRemoteAddr();
}
return ip;

在网上找到资料 request.getHeader("X-Forwarded-For"); 获取到得值为null ,ip = request.getRemoteAddr();这个获取的Ip不是真实的客户端IP,我想可能是我的apache配置有问题。请教高手!

作者: gaozhlzh   发布时间: 2011-10-18

自己顶一下。请教高手

作者: gaozhlzh   发布时间: 2011-10-18

热门下载

更多