通过代理查找客户端IP
当我的网站收到通过代理的连接时,我始终假设客户端 IP(如果提供)是 X-Forwarded-For HTTP 标头。但我见过也有
Client-IP
的情况。
如果两个标头都存在并且它们的信息不匹配,是否有一个比另一个更好的选择?
When my site receives a connection that's coming through a proxy, I've always assumed that the client IP (if provided) is the first item in the comma-delimited list of IP addresses in the X-Forwarded-For
HTTP header. But I've seen cases where there's also Client-IP
.
If both headers exist and their information does not match, is there one that's a better choice than the other?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的。使用 X-Forwarded-For。它是在这些情况下使用的标准标头
编辑:取自维基百科( http:// en.wikipedia.org/wiki/X-Forwarded-For ):
"大多数代理服务器都支持 X-Forwarded-For 字段,包括 Squid,[1] Apache mod_proxy,[2] Pound、[3]HAProxy、[4] Varnish 缓存、[5] IronPort Web 安全设备、[6] CAI Networks WebMux、ArrayNetworks、Radware 的 Appdirector 和 Web Server Director、F5 Big-IP、[7] Blue Coat ProxySG、[ 8] Cisco Cache Engine、McAfee Web Gateway、Phion Airlock、Finjan's Vital Security、NetApp NetCache、jetNEXUS、Crescendo Networks 的 Maestro、 Microsoft ISA Server 2004/2006 与 Winfrasoft X-Forwarded-For for ISA Server 和 Microsoft Forefront TMG 2010 与 Winfrasoft X-Forwarded-For for TMG 或 XFF-Filter.dll 免费 Web 过滤器[9]。
许多 Web 服务器(包括 Apache)都支持 X-Forwarded-For 日志记录。微软 IIS 6.0 和7.0 可以使用名为 Winfrasoft X-Forwarded-For for IIS 的第三方 ISAPI 过滤器来完成此任务。 IIS 7.0 还可以使用 HTTP 模块进行此过滤 [1]。”
Yes. use X-Forwarded-For. it is the standard header to use in these cases
edit: taken from the wikipedia ( http://en.wikipedia.org/wiki/X-Forwarded-For ):
"The X-Forwarded-For field is supported by most proxy servers, including Squid,[1] Apache mod_proxy,[2] Pound,[3]HAProxy, [4] Varnish cache,[5] IronPort Web Security Appliance,[6] CAI Networks WebMux, ArrayNetworks, Radware's Appdirector and Web Server Director, F5 Big-IP,[7] Blue Coat ProxySG,[8] Cisco Cache Engine, McAfee Web Gateway, Phion Airlock, Finjan's Vital Security, NetApp NetCache, jetNEXUS, Crescendo Networks' Maestro, Microsoft ISA Server 2004/2006 with Winfrasoft X-Forwarded-For for ISA Server and Microsoft Forefront TMG 2010 with Winfrasoft X-Forwarded-For for TMG or XFF-Filter.dll free web filter[9].
X-Forwarded-For logging is supported by many web servers including Apache. Microsoft IIS 6.0 & 7.0 can use a third party ISAPI filter called Winfrasoft X-Forwarded-For for IIS to accomplish this task. IIS 7.0 can also use a HTTP Module for this filtering [1]."