-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
X-Forwarded-Host header is copied into the Host header #2463
Comments
@octete please update to 0.14.0 |
we still have this in the nginx.tmpl in 0.14.0:
|
We are also suffering from this "feature" (bug), we have an apache httpd server in front of the ingress nginx (due to legacy setup of environment), and it's mod_balancer does exactly this, it adds a comma separated list of host names to the x_forwarded_host header, breaking the upstream http host header. |
Just to reiterate here: https://httpd.apache.org/docs/2.2/mod/mod_proxy.html#x-headers
|
We also faced the same issue. One service (using Zuul) proxy request to another service. It seems like Zuul (or our apache in front of it) sets a comma separated list to the x_forwarded_host header which returns a 400 (Bad Request) response. Edit: For people facing the same issue but still want to use versions after 0.10.2: |
We just force x-forwarded-host to be the appropriate value in our edge proxies, but it would be nice if this behavior could be fixed to be complaint with the header documentation. It's not even a real standard, so at the least the ingress needs to parse x-forwarded-host and only set host if the contents are valid. |
I am facing a problem with this as well. I think the Host header should not be touched and leave the upstream to decide what to do with the x-forwarded-host header. |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Can anyone explain why the ingress should touch the The only modification strategy I could think of that would make sense to me would be if it prepended the |
Per @benhamill's comment, this behavior makes the nginx ingress not transparent. If I have an existing setup of: And my backend is configured to use the After the migration with the following setup: The |
Another question, why does it make sense to set Host and X-Forwarded-Host to the same value?
|
If you're experiencing this issue you may be able to work around it with an annotation on your ingress like
|
The reason for this is that right now we have only one template for all the scenarios where the ingress controller could be used. This means we need to consider all this logic https://github.com/kubernetes/ingress-nginx/blob/master/rootfs/etc/nginx/template/nginx.tmpl#L269 before the generation of the final nginx.conf file. I want to split all this into several "profiles", having sane defaults (like when you enable proxy-protocol) and also allowing the user to define custom behaviors. That said, this is just an idea in my TODO list |
Stale issues rot after 30d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Workaround as described by @carl-youngblood didn't seem to work for me, but adding the following to the nginx configmap did.
|
Rotten issues close after 30d of inactivity. Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
@fejta-bot: Closing this issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Hi, I'm still facing the same issue with 0.22 version, once I set through CFM this value /reopen |
@paovitali: You can't reopen an issue/PR unless you authored it or you are a collaborator. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
hi |
have you found any solution for this issue |
You absolutely saved my life. These three lines of configuration-snippet solved the issue for me, which has bitten me twice:
Thank you so much! |
@daniel-kun That's wonderful! My pleasure. |
Thanks @aiman-alsari ,it worked for version 20.1 |
again +1 |
Thanks @michelvocks, this was the only solution for me here. The problem OP has described is still happening as reported. Using ingress-nginx chart v1.4.0, on GKE 1.22.15-gke.1000 (service behind ingress is httpd:2.4 with a pretty vanilla config). |
Is this a request for help?
Yes, and maybe a bug report. I wanted to explain the situation that I'm seeing, before filling a bug report, or asking for some configuration changes.
What keywords did you search in NGINX Ingress controller issues before filing this one? (If you have found any duplicates, you should instead reply there.):
I have found related entries:
#910
#911
#2030
These are either closed, or referring to the whole set of
X-Forwarded-*
headers, thus opening this one.Is this a BUG REPORT or FEATURE REQUEST? (choose one):
Kind of a bug report.
NGINX Ingress controller version:
0.11.0
Kubernetes version (use
kubectl version
):Environment:
What happened:
The nginx ingress controller is rewriting the
X-Forwarded-Host
header into theHost
header. As per https://tools.ietf.org/html/rfc7239, that header seems to be an optional, informational header.It can, however, have more than one host appended, like:
In our setup, we are using Fastly as our frontend, which uses our main load balancers to route traffic between two different kubernetes clusters in GKE running an ingress controller. Fastly does set the
X-Forwarded-Host
header with multiple hosts appended to it, separate by commas, as per the example above. This happens, seemingly, when Fastly reroutes traffic between their datacentres. Our front end load balancers pass that header intact to the ingress controller. The ingress controller, however, copies it into theHost
header, and this header then gets passed to the service running in k8s, which is Jetty based, as:At which point, Jetty returns with a 400 HTTP error, as it's an illegal
Host
header.What you expected to happen:
Not rewrite
X-Forwarded-Host
when it has more than one value to theHost
header.How to reproduce it (as minimally and precisely as possible):
You can easily reproduce it with
to the echoserver. You can also tcpdump on the receiving end. For a full test, you can hit Jetty too.
Anything else we need to know:
This is just an issue I wanted to raise, so my request is for help/solutions to this issues. It seems to me like a bug as you can have multiple hosts appended to
X-Forwarded-Host
, which is illegal for theHost
header, but I might be missing something. Let me know what your thoughts are on this, please.Thank you very much.
The text was updated successfully, but these errors were encountered: