问题描述
我知道标头 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.
HTTP_CLIENT_IP
和HTTP_X_FORWARDED_FOR
有什么区别?- 为什么一个人的价值观会与另一个不同?
- 在哪里可以找到有关这些标头的确切定义的资源.
推荐答案
这些标题都没有正式标准化.因此:
Neither of these headers are officially standardised. Therefore:
HTTP_CLIENT_IP 和 HTTP_X_FORWARDED_FOR 有什么区别?
- 无法说.不同的代理可能会实现这些,也可能不会.实现可能因一个代理而异,也可能不会.缺乏标准会产生问号.为什么一个值会与另一个不同?
- 参见第 1 点.但是,从纯粹的实际角度来看,我能看到这些值不同的唯一原因是如果超过涉及一个代理 -X-Forwarded-For:
标头可能包含转发链的完整跟踪,而Client-IP:
标头将包含实际客户端知识产权.然而,这纯粹是猜测.我在哪里可以找到有关这些标头的确切定义的资源.
- 你不能.见第 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.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 - theX-Forwarded-For:
header might then contain a complete track of the forwarding chain, whereas theClient-IP:
header would contain the actual client IP. This is pure speculation, however.Where can I find resources on the exact definition of these headers.
- You can't. See point 1.
似乎确实有关于 X- 的某种事实上的标准Forwarded-For:
标头,但 请参阅下面的评论.
There does seem to be some kind of de-facto standard regarding the X-Forwarded-For:
header, but 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 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!