X-Forwarded-For
General Summary
Section titled “General Summary”Identifies the original IP address of a client connecting through a proxy or load balancer.
Detailed Description
Section titled “Detailed Description”The X-Forwarded-For (XFF) header is a de-facto standard request header for identifying the originating IP address of a client connecting to a web server through an HTTP proxy or load balancer. Without this header, the backend server would incorrectly assume the IP address of the load balancer was the user’s actual IP.
Use Cases (When, Why, and How)
Section titled “Use Cases (When, Why, and How)”When to Use It
Section titled “When to Use It”Load balancers (like AWS ALB or Nginx) automatically inject this header into HTTP requests before forwarding them to internal backend servers.
Why to Use It
Section titled “Why to Use It”It is essential for logging, geographic IP routing, and rate-limiting. If your backend rate-limits based on the immediate TCP connection IP, it will end up rate-limiting your own load balancer and taking the site offline.
How to Use It
Section titled “How to Use It”It is a comma-separated list of IP addresses. The first IP is the original client, and subsequent IPs represent proxies the request passed through.
X-Forwarded-For: 203.0.113.195, 70.41.3.18, 150.172.238.178
Example
Section titled “Example”X-Forwarded-For: 203.0.113.195, 70.41.3.18