Forwarded Header
Table of Content
The Forwarded header is an HTTP feature that allows web applications to obtain information about the protocol (HTTP or HTTPS), host and IP address of the connected client. This information is typically important for applications behind load balancers or reverse proxies to enable them to make decisions based on the client’s original (not proxy) connection specifications.
Syntax
Forwarded: for="_client-ip_"; host="_host_"; proto="_protocol_"
In the above syntax, the "client-ip", "host", and "protocol" are placeholders for the actual client IP, host, and protocol respectively.
Directives
The Forwarded header can accept multiple directives including for
, by
, host
, and proto
. The for
directive identifies the client that initiated the request. The by
directive discloses the intermediate; usually a proxy's interface, that received the request. The host
discloses the host request header field as received by the proxy. The proto
reveals the protocol (HTTP or HTTPS) used in the original request.
Examples
Forwarded: for="192.0.2.60";host="example.com";proto="http"
Forwarded: for="2001:db8:cafe::17";proto="https"
The first example illustrates the Forwarded header for a client with IP "192.0.2.60", using HTTP protocol on the site "example.com". The second example shows the Forwarded header for a client with IP "2001:db8:cafe::17", using the HTTPS protocol.
Browser Compatibility
Browser | Compatibility |
---|---|
Chrome | Supported |
Firefox | Supported |
Safari | Not Supported |
Opera | Supported |
Edge | Supported |
Please note that the above compatibility table is an informative guess and could change based on updates by the browser developers.
How to modify Forwarded header
ModHeader is a Chrome extension that allows you to modify and manipulate the HTTP request headers sent to servers. It lets you add, modify, and remove request headers. Here is how you can modify the Forwarded header through ModHeader.
- Install ModHeader from the Chrome web store.
- Click on the ModHeader icon to open the extension.
- In the 'Request Headers' section, click on the '+' button.
- In the 'Name' field, enter 'Forwarded'.
- In the 'Value' field, enter the header value. For example, for="192.0.2.60";host="example.com";proto="http"
Modifying the Forwarded header can help in emulating different client connections and help with testing and debugging an application's reaction to different client connection situations.