New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Empty X-Forwarded-Host header #1968
Comments
Thanks a lot @adriangonz ! |
knrt10
added a commit
that referenced
this issue
May 20, 2024
The header was not getting set correctly and returning an empty string Fixes: #1968 Signed-off-by: Kautilya Tripathi <[email protected]>
knrt10
added a commit
that referenced
this issue
May 21, 2024
The header was not getting set correctly and returning an empty string Fixes: #1968 Signed-off-by: Kautilya Tripathi <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Problem
In Go, trying to access the
Host
header directly of a request object throughr.Header.Get("Host")
always return an empty string - regardless of whether the header is actually set or not. Instead, you need to use ther.Host
field (which under the hood will just read the actual header). This leads to theX-Forwarded-Host
header being left empty when requests are proxied to the cluster API Server:headlamp/backend/cmd/headlamp.go
Line 1010 in d4f7748
This can cause problems when the API Server is fronted by some reverse proxies (e.g. NGINX) which do a strict implementation of the HTTP 1.1 protocol - where the
Host
(orX-Forwarded-Host
) has to always be present. Otherwise, every request sends back a400
response with an error along the following lines:Proposed Solution
To work around the above, it should be enough to just read the
Host
header directly viar.Host
, i.e. doing something like (note thatr.Host
is already set on the line above):The text was updated successfully, but these errors were encountered: