HTTP headers | X-Forwarded-Proto

The HTTP headers are used to communicate between client and server. HTTP headers let the client and server pass additional information with an HTTP request or response. X-Forwarded-Proto (XPF) header is used to identifying the protocol that the client used to connect with a proxy or load balancer. It can be HTTP or HTTPS. Your server access log usually contains information about the protocol used between server and load balancer, but it does not contain any information about the protocol used between the client and load balancer. To get information about which protocol used between client and load balancer, we can use the X-Forwarded-Proto request header. Using this header, the client can make an HTTP request to an HTTPS-only resource.

Syntax:

X-Forwarded-Proto: <protocol>

Directives:



  • <protocol>: This contains an X-Forwarded-Proto request header for a request that originated from the client(http or https).

Example 1: The following example contains an X-Forwarded-Proto request header for a request that originated from the client as an HTTP request:

filter_none

edit
close

play_arrow

link
brightness_4
code

// X-Forwarded-Proto: originatingprotocol
X-Forwarded-Proto: http

chevron_right


Example 2: The following example contains an X-Forwarded-Proto request header for a request that originated from the client as an HTTPS request:

filter_none

edit
close

play_arrow

link
brightness_4
code

// X-Forwarded-Proto: originatingprotocol
X-Forwarded-Proto: https

chevron_right


Example 3: This eaxmple is for other non-standard form.

filter_none

edit
close

play_arrow

link
brightness_4
code

# Microsoft
Front-End-Https: on
  
X-Forwarded-Protocol: http
X-Forwarded-Ssl: on 
X-Url-Scheme: http

chevron_right


Note: This HTTP headers X-Forwarded-Proto is useful when you want to keep a record of the protocol client and load balancer.
Supported Browsers: Compatibility for the HTTP headers X-Forwarded-Proto for the browsers still unknown.



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.