X-Forwarded-Host Header

Table of Content

The X-Forwarded-Host (XFH) header is a de-facto standard header for identifying the original host requested by the client in the Host HTTP request header. It is primarily used for proxying and load balancing to show which server the client initially connected to. Firewalls, proxy servers, or load balancers often replace the host name with their own while forwarding the HTTP requests. X-Forwarded-Host is crucial in cases where knowing the original host is important for handling the request correctly.


X-Forwarded-Host: <host>


The X-Forwarded-Host header accepts a single directive: <host>. This directive stands for an internet hostname, which must be compliant with specification RFC 3986.


Consider an HTTP request initially made to proxy.example.com, which is then proxied to example.net. The X-Forwarded-Host header for such a case would look as:

X-Forwarded-Host: proxy.example.com

Browser Compatibility

Browser Compatibility
Chrome Supported
Firefox Supported
Safari Supported
Opera Supported
Edge Supported

How to modify X-Forwarded-Host header

ModHeader is a Chrome extension that allows you to add, modify, and remove HTTP request headers. Here is how you can use it to change the X-Forwarded-Host header:

  1. Install the ModHeader extension from the Chrome web store.
  2. Click on the ModHeader icon in the top right corner to open it.
  3. In the 'Request headers' section, click 'Add' to create a new row.
  4. In the 'Name' field of the new row, enter "X-Forwarded-Host".
  5. In the 'Value' field, enter the host you want to appear in the X-Forwarded-Host header.
  6. Now all your requests will include this header!

This can be useful for testing your applications' behavior when they're behind a proxy or a load balancer.