You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description:
Today envoy does not seem to forward the original host in a X-Forwarded-Host header, it just rewrites the original one and apparently there is no way to get the original host back again.
I found a reference for this header in the source code but it seems it is not being used anywhere else: (
Reacted by Hou 42, Nathan H. Leung, Yannis Zarkadas, Todd Tomkinson, Youssef Azrak, Aniruddha Maru, Artyom Gatalsky, Patrik Palmér, Alex Avizov, tal-sapan and 3 more
Hello, I would like to try to add this feature and need some guidance.
Does it make sense to check for the options host_rewrite and auto_host_rewrite and copy the original host to X-Forwarded-Host header when the change is about to happen?
Should there be any configuration that enable/disable this header?
@pedro-tramontin SGTM. I'm not sure if we want to config guard it or not. On one hand, I think it would be OK to not config guard if we only set when a host mutation happens as you point out. On the other hand, it's possible that upstreams are not expecting us to set it and we might break them. @envoyproxy/maintainers any thoughts?
Hi all!
This is a feature we (Arrikto) would like to have in Envoy, as it's something we rely upon to build correct URLs even with multiple proxies in the request's journey.
I am really unfamiliar with advanced C++ code, but I read through the docs and tried to take a stab at it.
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.
If request host/authority is changed when the request is proxied, set x-forwarded-host to old x-forwarded host + old host: x-forwarded-host = append(x-forwarded-host, host)
After reading through the Envoy architecture, I see that HTTP Connection Manager converts bytes to HTTP and passes traffic through an HTTP Filter Chain.
The Router HTTP Filter should be the one responsible for making the decision to change a request's host/authority, so I am looking into it.
After reading the architecture documents and comparing it with the code structure, I was very happy to find out that things were very nicely organized (kudos to maintainers) and I managed to make some progress.
IMO we don't need to do any parsing here as we pass through the host unchanged in almost all cases. We only need to (optionally) set the header when we do one of the header mutation functions?
Activity
pedro-tramontin commentedon Mar 15, 2019
Hello, I would like to try to add this feature and need some guidance.
Does it make sense to check for the options host_rewrite and auto_host_rewrite and copy the original host to X-Forwarded-Host header when the change is about to happen?
Should there be any configuration that enable/disable this header?
mattklein123 commentedon Mar 15, 2019
@pedro-tramontin SGTM. I'm not sure if we want to config guard it or not. On one hand, I think it would be OK to not config guard if we only set when a host mutation happens as you point out. On the other hand, it's possible that upstreams are not expecting us to set it and we might break them. @envoyproxy/maintainers any thoughts?
yanniszark commentedon Feb 22, 2020
Hi all!
This is a feature we (Arrikto) would like to have in Envoy, as it's something we rely upon to build correct URLs even with multiple proxies in the request's journey.
I am really unfamiliar with advanced C++ code, but I read through the docs and tried to take a stab at it.
According to MDN's definition for X-Forwarded-For:
A simple example to illustrate:
So the algorithm for this functionality is:
If request host/authority is changed when the request is proxied, set x-forwarded-host to old x-forwarded host + old host:
x-forwarded-host = append(x-forwarded-host, host)After reading through the Envoy architecture, I see that HTTP Connection Manager converts bytes to HTTP and passes traffic through an HTTP Filter Chain.
The Router HTTP Filter should be the one responsible for making the decision to change a request's host/authority, so I am looking into it.
After reading the architecture documents and comparing it with the code structure, I was very happy to find out that things were very nicely organized (kudos to maintainers) and I managed to make some progress.
In particular, this part seems interesting:
envoy/source/common/router/router.cc
Line 524 in 1a8fac9
What I plan to do is:
@pedro-tramontin @mattklein123 any tips / directions would be highly welcome.
This is very new territory for me 😄
mattklein123 commentedon Feb 23, 2020
IMO we don't need to do any parsing here as we pass through the host unchanged in almost all cases. We only need to (optionally) set the header when we do one of the header mutation functions?
lambdai commentedon Apr 12, 2021
@pedro-tramontin (since you are assigned) and @arun-vasudev (since you are the author of the latest PR) Are you still working on this?
Any update?
arun-vasudev commentedon Apr 15, 2021
I will address the review comments and upload a new patch by April 18. @lambdai. I had lost track of this!
blained3 commentedon May 5, 2021
@arun-vasudev Has the patch been released?
tbarrella commentedon May 21, 2021
Hi @arun-vasudev, do you still intend to work on this?
arun-vasudev commentedon May 26, 2021
Hi @tbarrella, I will send out the new patch in a day or so. Was busy at work.
Ido-Itz commentedon Jul 29, 2021
Hi folks. I was wondering if this is still planned. Any new updates on this topic?
Really looking forward to this feature
arun-vasudev commentedon Oct 14, 2021
I am working on it again!
Support for x-forwarded-host header. (#18639)