Can X-FORWARDED-FOR contain multiple IP addresses? If so, why? An illustrative example would be great.
Asked
Active
Viewed 4.7k times
35
Hassan Baig
- 2,745
- 14
- 36
- 50
2 Answers
43
Yes, if a request is chained through more than one proxy server, then each proxy should add the IP of the preceding one to the existing X-Forwarded-For header so that the entire chain is preserved.
Mike Scott
- 8,228
28
From https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For
X-Forwarded-For: <client>, <proxy1>, <proxy2>
If a request goes through multiple proxies, the IP addresses of each successive proxy is listed. This means, the right-most IP address is the IP address of the most recent proxy and the left-most IP address is the IP address of the originating client.
Examples:
X-Forwarded-For: 2001:db8:85a3:8d3:1319:8a2e:370:7348
X-Forwarded-For: 203.0.113.195
X-Forwarded-For: 203.0.113.195, 70.41.3.18, 150.172.238.178
Giacomo1968
- 3,553
- 29
- 42
Sindre
- 281
- 3
- 2