-
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-Port is always fixed to 443. #11138
Comments
This issue is currently awaiting triage. If Ingress contributors determines this is a relevant issue, they will accept it by applying the The 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. |
/remove-kind bug This is a ingress-controller, that processes ingress rules, that almost always contain a TLS section in real-world use case, and nobody wants their users to type a port number in browser or force suffix a port number in api calls. That is stating the obvious that port 443 is accepted standard. To present the real info to the backend pod, headers like Several apps like Tomcat or others listen on 8080 or 8443 etc. But TLS config for them is a option and not defaulted out of the box. Hence the out of the box use case of ingress is termination on the the controller for TLS and backend plaintext HTTP communication to app. And then some people go around this by configuring SSL-Passthrough so TLS termination is on the pod. Hence detailed descriptive data and logic provided in this issue description will help a reader, the specs & design based on which the current behaviour is a bug. Hope you provide that. The new bug report contains questions in the template. Answer them as that creates action items instead of reading this kind of vague content. |
Currently, X-Forwarded-Port is transmitting lie information, not truth information. I still don't understand why this isn't a bug. This causes cors rejection in Spring framework. |
Your values file yaml hints that you are using hostPorts and you have ignored all the questions that are asked in the template of a new bug report. So you can yourself set the bug tag if you want to but you are not really helping a reader fully understand the small tiny intricate critical details. For example there is no data on the impact of hostPorts when compared to a normal service of --type LoadBalancer being the termination. And on how all this impacts kube-proxy etc. |
@jclab-joseph
could be related to your case? |
This is stale, but we won't close it automatically, just bare in mind the maintainers may be busy with other tasks and will reach your issue ASAP. If you have any question or request to prioritize this, please reach |
@grigoni That's probably right.
|
The basic issue description is false and does not match a real practical curl test as seen below
Since there is no traction on this, I will close the issue for now. Please re-open once there is data posted here or the issue description has improved to show the proof of a problem iwth the controller. /close |
@longwuyuan: 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. |
Your test clearly used HTTP when the original issue demonstrated this behavior over HTTPS. The expected behavior is that ingress-nginx would properly set the value for "X-Forwarded-Port" in the header based on the port specified in the original request. This is undocumented and bewildering behavior. test instructions:
|
@aescaler-raft I will reopen and run test with HTTPS. Please confirm the below info for the test ;
|
@longwuyuan: Reopened 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-sigs/prow repository. |
@aescaler-raft also help out in the following way.
|
This is what I did while waiting for a values file from you (for kind cluster install of controller) and the curl ;
|
Lets say you want to do some hardening and to run the controller in a port higher than 1000, creating a LoadBalancer service at port 80/443 and translating traffic into a higher targetPort to the controller:
This results in the source IP not being preserved, the ingress controller sees source IP as the service endpoint IP for the ingress controller, here is how the headers look like to the workload:
In AKS you don't have proxy protocol and you have to rely on this technique to pass the source IP to workloads. |
@pdefreitas unfortunately, it is true that AKS LB does not support proxy-protocol. Microsoft has mentioned in clearly and without any ambiguity, in their Azure/AKS docs. |
@longwuyuan yes I added that detail for awareness. In this scenario it fully limits which ports we are able to run HTTPS while preserving the source IP because X-Forwarded-Port is fixed to 443. |
We are facing this issue. We have Azure Frontdoor -> Azure Load Balancer -> NGINX Ingress -> Keycloak. Keycloak receives X-Forwarded-Port 80 when accessing via HTTPS. Is there any standard/official workaround for this? Currently, we configured Azure Frontdoor to set X-Forwarded-Port 443, and it works, but we are wondering if this is the correct solution. |
It will be good if I am corrected but I think all docs say that the X-Forwarded-For is received by the controller from the LB so the controller does not set that header by itself, or the other X-Forwarded headers like ip or proto or port. |
What happened:
X-Forwarded-Port is always fixed to 443.
Even if change --https-port, it is always fixed to 443.
Because of this, we got the following results:
In spring-boot, 403 is caused if the origin port and X-Forwarded-Port are different.
What you expected to happen:
It should be changed to https listen port.
NGINX Ingress controller version (exec into the pod and run nginx-ingress-controller --version.):
Kubernetes version (use
kubectl version
): v1.27.11+rke2r1How to reproduce this issue:
values.yaml:
The text was updated successfully, but these errors were encountered: