Find answers, guides, and tutorials to supercharge your content delivery.

X-Forwarded-Host (XFH)

Updated on October 4, 2018
X-Forwarded-Host (XFH)

What Is X-Forwarded-Host (XFH)?

The X-Forwarded-Host HTTP header is used to forward the original Host header value to the origin server. This can be useful in the event that a proxy or CDN rewrites the Host header, for example to: According to RFC 7230, section 5.4,

When a proxy receives a request with an absolute-form of request-target, the proxy MUST ignore the received Host header field (if any) and instead replace it with the host information of the request-target.

For a request from a KeyCDN edge server, the above quote means that unless the Forward Host Header option is enabled, the Host header becomes your_origin_host and the XFH header contains the original Host value. For example:

GET /image.jpg HTTP/2
X-Forwarded-Host: <zonename>-<id>
X-Forwarded-Scheme: http
X-Pull: KeyCDN
Connection: close
Accept: */*
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36
Accept-Language: en-US,en;q=0.8,de;q=0.6,ja;q=0.4
Cookie: foobar

The example above shows that the Host header is replaced with the domain URL of the website while the X-Forwarded-Host contains the original Host header value (either your Zone Alias or Zone URL).

Using XFH With KeyCDN

When a request is made from a client for an asset on a KeyCDN edge server, the Host will be either the defined Zone URL or Zone Alias (e.g. If the content is not cached on the edge server, it will make a request to the origin server for the content. The Host header for the request from the edge server will be your_origin_host and will include the X-Forwarded-Host header. The XFH header value will be the originally requested host (either the Zone Alias or Zone URL) to let the origin server know what hostname the request is coming from, similar to:

X-Forwarded-Host: <zonename>-<id>

The XFH header is useful when wanting to use one Zone to manage multiple sites. The image below demonstrates the use of the X-Forwarded-Host header in this scenario.

The XFH contains the Zone Alias of each request allowing the origin server to distinguish between websites and deliver the appropriate assets to each Zone Alias.


With X-Forwarded-Host header is a valuable HTTP header for determining which Host was originally used in the case that there is a proxy or CDN between the client and origin server. As seen in the example above, making the origin server aware of what the original host header is, can prove to be very useful for certain tasks such as using one Zone to manage multiple sites.

Supercharge your content delivery 🚀

Try KeyCDN with a free 14 day trial, no credit card required.

Get started
KeyCDN uses cookies to make its website easier to use. Learn more about cookies.