HTTP_CLIENT_IP和HTTP_X_FORWARDED_FOR有什么区别? [英] What is the difference between HTTP_CLIENT_IP and HTTP_X_FORWARDED_FOR?

查看:550
本文介绍了HTTP_CLIENT_IP和HTTP_X_FORWARDED_FOR有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知,头代码 HTTP_X_FORWARDED_FOR 是由代理服务器设置的,用来标识通过代理发出HTTP请求的主机的IP地址。我听说声称头部 HTTP_CLIENT_IP 是为类似的目的而设置的。

I understand that a header HTTP_X_FORWARDED_FOR is set by proxy servers to identify the ip-address of the host that is making the HTTP request through the proxy. I've heard claims that the header HTTP_CLIENT_IP is set for similar purposes.


  1. HTTP_CLIENT_IP HTTP_X_FORWARDED_FOR

  2. 有什么区别?

  1. What is the difference between HTTP_CLIENT_IP and HTTP_X_FORWARDED_FOR?
  2. Why would one have different values than the other?
  3. Where can I find resources on the exact definition of these headers.

推荐答案

这些头文件都没有正式标准化。因此:

Neither of these headers are officially standardised. Therefore:


  1. HTTP_CLIENT_IP和HTTP_X_FORWARDED_FOR有什么不同? - 这是不可能的说。不同的代理可以实现这些,也可以不实现。这些实现可能因代理的不同而不同,而且可能不一样。缺少一个标准会产生问号。

  2. 为什么会有不同的值? - 见第1点。但是,从纯粹的实践角度来看,我可以看到这些具有不同价值的唯一原因是如果涉及多个代理 - X-Forwarded-For:头可能然后包含转发链的完整跟踪,而 Client-IP:标题将包含实际的客户端IP。然而,这是纯粹的推测。

  3. 在哪里可以找到这些头文件的确切定义的资源。 - 您不能。请参阅第1点。
  1. What is the difference between HTTP_CLIENT_IP and HTTP_X_FORWARDED_FOR? - it is impossible to say. Different proxies may implement these, or may not. The implementations may vary from one proxy to the next, and they may not. A lack of a standard breeds question marks.
  2. Why would one have different values than the other? - See point 1. However, from a purely practical point of view, the only reason I can see for these having different values is if more than one proxy was involved - the X-Forwarded-For: header might then contain a complete track of the forwarding chain, whereas the Client-IP: header would contain the actual client IP. This is pure speculation, however.
  3. Where can I find resources on the exact definition of these headers. - You can't. See point 1.

似乎有 For某种事实上的标准有关 X-Forwarded-For:标题,但是给出没有RFC它定义它不能被依赖见下面的注释。

There does seem to be some kind of de-facto standard regarding the X-Forwarded-For: header, but given that there is no RFC that defines it this cannot be relied upon see comment below.

作为一个附注, Client-IP:头文件应该是 X-Client-IP:,因为它是一个'用户自定义'头文件。

As a side note, the Client-IP: header should by convention be X-Client-IP: since it is a 'user-defined' header.

这篇关于HTTP_CLIENT_IP和HTTP_X_FORWARDED_FOR有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆