Tutorials  Articles  Notifications  Login  Signup


RK

Rajan Kumar

Founder at HackersFriend July 18, 2021, 12:59 p.m. ⋅ 1130 views

What is HTTP header X-Forwarded-Host ?


The HTTP X-Forwarded-Host header is the part of HTTP header that contains information for identifying the original host requested by the client. It is  de-facto standard header.

Real life usage

Suppose you have multiple location dependent servers to serve your users, and a load balancer on front of it. In this case, host of load balancer might differ from the host address of servers. Also, host of servers may vary as per their location. Here, HTTP X-Forwarded-Host header can be used to identify which server does the user wants to use for his request. Normally, this is helpful in location dependent servers.

Syntax

X-Forwarded-Host: <host>

Here, host will be the host address of server.

Example

X-Forwarded-Host: www.hackersfriend.com

To check the X-Forwarded-Host of any page you visited, you can go to Inspect Element then Network and then check the request header for X-Forwarded-Host.



HackerFriend Logo

Join the community of 1 Lakh+ Developers

Create a free account and get access to tutorials, jobs, hackathons, developer events and neatly written articles.


Create a free account