Forwarded header
The HTTPForwardedrequest header contains information that may be added byreverse proxy servers (load balancers, CDNs, etc.) that would otherwise be altered or lost when proxy servers are involved in the path of the request.
For example, if a client is connecting to a web server through an HTTP proxy (or load balancer), server logs will only contain the IP address, host address, and protocol of the proxy; this header can be used to identify the IP address, host, and protocol, of the original request.The header is optional and may be added to, modified, or removed, by any of the proxy servers on the path to the server.
This header is used for debugging, statistics, and generating location-dependent content.By design, it exposes privacy sensitive information, such as the IP address of the client.Therefore, the user's privacy must be kept in mind when using this header.
The alternative and de-facto standard versions of this header are theX-Forwarded-For,X-Forwarded-Host andX-Forwarded-Proto headers.
| Header type | Request header |
|---|---|
| Forbidden request header | No |
In this article
Syntax
Forwarded: by=<identifier>;for=<identifier>;host=<host>;proto=<http|https>Directives arekey=value pairs, separated by a semicolon.
If there are multiple proxy servers between the client and server, they may each specify their own forwarding information.This can be done by adding a newForwarded header to the end of the header block, or by appending the information to the end of the lastForwarded header in a comma-separated list.
Directives
byOptionalThe interface where the request came in to the proxy server.The identifier can be:
- an obfuscated identifier (such as "hidden" or "secret").This should be treated as the default.
- an IP address (v4 or v6, optionally with a port, and ipv6 quoted and enclosed in square brackets)
- "unknown" when the preceding entity is not known (and you still want to indicate that forwarding of the request was made)
forOptionalThe client that initiated the request and subsequent proxies in a chain of proxies.The identifier has the same possible values as the
bydirective.hostOptionalThe
Hostrequest header field as received by the proxy.protoOptionalIndicates which protocol was used to make the request (typically "http" or "https").
Examples
>Using theForwarded header
Forwarded: for="_mdn"# case insensitiveForwarded: For="[2001:db8:cafe::17]:4711"# separated by semicolonForwarded: for=192.0.2.60;proto=http;by=203.0.113.43# Values from multiple proxy servers can be appended using a commaForwarded: for=192.0.2.43, for=198.51.100.17Transitioning fromX-Forwarded-For toForwarded
If your application, server, or proxy supports the standardizedForwarded header, theX-Forwarded-For header can be replaced.Note that an IPv6 address is quoted and enclosed in square brackets inForwarded (unlike in theX-Forwarded-For header).
X-Forwarded-For: 192.0.2.172Forwarded: for=192.0.2.172X-Forwarded-For: 192.0.2.43, 2001:db8:cafe::17Forwarded: for=192.0.2.43, for="[2001:db8:cafe::17]"Specifications
| Specification |
|---|
| Forwarded HTTP Extension> |
See also
X-Forwarded-ForX-Forwarded-HostX-Forwarded-ProtoVia– provides information about the proxy itself, not about the client connecting to it.