首页 > 代码库 > 开发问题解决志
开发问题解决志
2014.5.5
获取客户端真实ip地址出现问题,解答如下:
When you have NAT (Network Address Translation) device before your servlet container request.getRemoteAddr()
returns the address of NAT , since it initiate a new connection.
To solve your problem you should configure you NAT to send in a header the IP of the original client. Then, to take the header from the request. In case you configure in NAT X-Forwarded-For header use this code: request.getHeader("X-Forwarded-For")
You function is correct, you can use it when you configure NAT.
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。