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

查看:92
本文介绍了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_IPHTTP_X_FORWARDED_FOR 有什么区别?
  2. 为什么一个人的价值观会与另一个不同?
  3. 在哪里可以找到有关这些标头的确切定义的资源.

推荐答案

这些标题都没有正式标准化.因此:

Neither of these headers are officially standardised. Therefore:

  1. HTTP_CLIENT_IP 和 HTTP_X_FORWARDED_FOR 有什么区别? - 无法说.不同的代理可能会实现这些,也可能不会.实现可能因一个代理而异,也可能不会.缺乏标准会产生问号.
  2. 为什么一个值会与另一个不同? - 参见第 1 点.但是,从纯粹的实际角度来看,我能看到这些值不同的唯一原因是如果超过涉及一个代理 - X-Forwarded-For: 标头可能包含转发链的完整跟踪,而 Client-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.

似乎确实有关于 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天全站免登陆