nginx - What is the difference between X-Forwarded-For and X-Real-IP?
伊谢尔伦
伊谢尔伦 2017-05-16 17:26:04
0
1
834

What is the difference between X-Forwarded-For and X-Real-IP?

After testing, I found that the IP obtained is the same.

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(1)
曾经蜡笔没有小新

Generally speaking, X-Forwarded-For是用于记录代理信息的,每经过一级代理(匿名代理除外),代理服务器都会把这次请求的来源IP追加在X-Forwarded-For

A request from 4.4.4.4, the header contains such a line

X-Forwarded-For: 1.1.1.1, 2.2.2.2, 3.3.3.3

means that the request is sent by 1.1.1.1 and passes through three layers of proxies. The first layer is 2.2.2.2 and the second layer is 3.3.3.3 , and the source IP of this request1.1.1.1发出,经过三层代理,第一层是2.2.2.2,第二层是3.3.3.3,而本次请求的来源IP4.4.4.4 is the third layer proxy

AndX-Real-IP,没有相关标准,上面的例子,如果配置了X-Read-IP, there may be two situations

// 最后一跳是正向代理,可能会保留真实客户端IP
X-Real-IP: 1.1.1.1
// 最后一跳是反向代理,比如Nginx,一般会是与之直接连接的客户端IP
X-Real-IP: 3.3.3.3

So, if there is only one layer of proxy, the values ​​of these two headers are the same

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template