当前位置:网站首页>X-Forwarded-For详解、如何获取到客户端IP
X-Forwarded-For详解、如何获取到客户端IP
2022-07-06 09:26:00 【一一空】
我们先看看官方定义
X-Forwarded-For
X-Forwarded-For (XFF) 在客户端访问服务器的过程中如果需要经过HTTP代理或者负载均衡服务器,可以被用来获取最初发起请求的客户端的IP地址,这个消息首部成为事实上的标准。在消息流从客户端流向服务器的过程中被拦截的情况下,服务器端的访问日志只能记录代理服务器或者负载均衡服务器的IP地址。如果想要获得最初发起请求的客户端的IP地址的话,那么 X-Forwarded-For 就派上了用场。
这个消息首部会被用来进行调试和统计,以及生成基于位置的定制化内容,按照设计的目的,它会暴露一定的隐私和敏感信息,比如客户端的IP地址。所以在应用此消息首部的时候,需要将用户的隐私问题考虑在内。
HTTP 协议中的 Forwarded 是这个消息首部的标准化版本。
X-Forwarded-For 也是一个电子邮件相关协议中用到的首部,用来表示一封电子邮件是从其他账户转发过来的。
| Header type | Request header |
|---|---|
| Forbidden header name | no |
语法
X-Forwarded-For: <client>, <proxy1>, <proxy2> 具体链接:X-Forwarded-For - HTTP | MDNX-Forwarded-For (XFF) 在客户端访问服务器的过程中如果需要经过HTTP代理或者负载均衡服务器,可以被用来获取最初发起请求的客户端的IP地址,这个消息首部成为事实上的标准。在消息流从客户端流向服务器的过程中被拦截的情况下,服务器端的访问日志只能记录代理服务器或者负载均衡服务器的IP地址。如果想要获得最初发起请求的客户端的IP地址的话,那么 X-Forwarded-For 就派上了用场。https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers/X-Forwarded-For
下面我用一张图给大家来描述X-Forwarded-For的采集过程

这个图中一共6个步骤,在用户发起网站访问时,针对x-forwarded-for的重要5个节点已做了描述,
举例是用户访问www.baidu.com
①将家庭局域网转换成小区局域网地址,这里还是局域网,只是更大;
②将小区局域网地址通过SNAT转换成公网地址:36.110.25.116;
2-3 Dns服务将访问的目标地址转换成具体的ip;
③被访问服务所在机房的入网设备ip:220.181.38.148;
④经过waf服务器:105.16.35.100;
⑤请求到达公司局域网代理服务器 101.25.48.201;
最后到达真正的业务服务器Server。这个时候从Server服务器上采集到的X-Forwarded-For地址如下:
X-Forwarded-For: 36.110.25.116,220.181.38.148,105.16.35.100,101.25.48.201
客户端IP proxy-ip proxy-ip proxy-ip
参考
边栏推荐
- C语言必背代码大全
- Research Report of exterior wall insulation system (ewis) industry - market status analysis and development prospect prediction
- JS --- detailed explanation of JS facing objects (VI)
- Hospital privacy screen Industry Research Report - market status analysis and development prospect forecast
- STM32 learning record: input capture application
- Research Report on market supply and demand and strategy of geosynthetics industry in China
- Research Report on market supply and demand and strategy of China's medical chair industry
- 学习记录:串口通信和遇到的错误解决方法
- JS --- all knowledge of JS objects and built-in objects (III)
- STM32 how to use stlink download program: light LED running light (Library version)
猜你喜欢

ucore lab7

Eslint--- error: newline required at end of file but not found (EOL last) solution

学习记录:TIM—电容按键检测

TCP的三次握手与四次挥手

ucorelab4

JS --- BOM details of JS (V)

JS --- all knowledge of JS objects and built-in objects (III)

D - Function(HDU - 6546)女生赛

Learning record: understand systick system timer and write delay function

学习记录:使用STM32F1看门狗
随机推荐
学习记录:TIM—基本定时器
Optimization method of path problem before dynamic planning
Cost accounting [24]
LeetCode#62. Different paths
学习记录:如何进行PWM 输出
Learning record: USART serial communication
信息安全-威胁检测-NAT日志接入威胁检测平台详细设计
E. Breaking the Wall
JS --- BOM details of JS (V)
F - Birthday Cake(山东省赛)
学习记录:TIM—电容按键检测
力扣刷题记录
学习记录:理解 SysTick系统定时器,编写延时函数
Market trend report, technological innovation and market forecast of pneumonia drugs obtained by Chinese hospitals
0-1背包問題(一)
1010 things that college students majoring in it must do before graduation
Cost accounting [22]
SSM框架常用配置文件
基于web的照片数码冲印网站
差分(一维,二维,三维) 蓝桥杯三体攻击