ingress-nginx: Unable to remove or update the NGINX added X-Forwarded-Proto header using `charts/ingress-nginx`
What happened:
Cannot remove or override the nginx ingress controller added X-Forwarded-Proto header value. Even though able to pass the customized proxy header using below values.yaml to helm install, but the URL still gets added with X-Forwarded-Proto: http header value.
controller:
proxySetHeaders:
X-Forwarded-Proto: ""
The nginx.conf inside the ingress controller pod shows the customized value is being added but the URLs still gets added with the first value and not the latest X-Forwarded-Proto value.
# kubectl exec -it nginx-ingress-ingress-nginx-controller-799b9ccd64-kvxxf -n myns sh
/etc/nginx $ cat nginx.conf|grep X-Forwarded-Proto
proxy_set_header X-Forwarded-Proto $pass_access_scheme;
proxy_set_header X-Forwarded-Proto "";
.
.
.
.
What you expected to happen: Expect to have the support for removing the nginx controller added X-Forwarded-* headers from the URLs.
If we manually exec into the nginx controller pod and change the “$pass_access_scheme” to “” for X-Forwarded-Proto, works as expected.
NGINX Ingress controller version (exec into the pod and run nginx-ingress-controller --version.):
/etc/nginx $ /nginx-ingress-controller --version
-------------------------------------------------------------------------------
NGINX Ingress controller
Release: v1.9.6
Build: 6a73aa3b05040a97ef8213675a16142a9c95952a
Repository: https://github.com/kubernetes/ingress-nginx
nginx version: nginx/1.21.6
-------------------------------------------------------------------------------
/etc/nginx $
Kubernetes version (use kubectl version):
# kubectl version
WARNING: This version information is deprecated and will be replaced with the output from kubectl version --short. Use --output=yaml|json to get the full version.
Client Version: version.Info{Major:"1", Minor:"27", GitVersion:"v1.27.6", GitCommit:"741c8db18a52787d734cbe4795f0b4ad860906d6", GitTreeState:"clean", BuildDate:"2023-09-13T09:21:34Z", GoVersion:"go1.20.8", Compiler:"gc", Platform:"linux/amd64"}
Kustomize Version: v5.0.1
Server Version: version.Info{Major:"1", Minor:"27", GitVersion:"v1.27.8", GitCommit:"66fee42707cd7f5a89f1987f7cb81b02dd19161c", GitTreeState:"clean", BuildDate:"2023-11-15T16:50:09Z", GoVersion:"go1.20.11", Compiler:"gc", Platform:"linux/amd64"}
Environment:
-
Cloud provider or hardware configuration: Kubeadm based setup
-
OS (e.g. from /etc/os-release): Linux
-
Kernel (e.g.
uname -a): Oracle Linux Server 7.8 -
Install tools: kubeadm
Please mention how/where was the cluster created like kubeadm/kops/minikube/kind etc.
-
Basic cluster related info:
kubectl versionkubectl get nodes -o wide
-
How was the ingress-nginx-controller installed:
- If helm was used then please show output of
helm ls -A | grep -i ingress# helm ls -A | grep -i ingress
- If helm was used then please show output of
nginx-ingress myns 1 2024-02-28 22:00:50.671827003 -0800 PST deployed ingress-nginx-4.9.1 1.9.6 ```
-
If helm was used then please show output of
helm -n <ingresscontrollernamespace> get values <helmreleasename># helm get values -n myns nginx-ingress USER-SUPPLIED VALUES: controller: admissionWebhooks: enabled: false allowSnippetAnnotation: true proxySetHeaders: X-Forwarded-Proto: "" -
If helm was not used, then copy/paste the complete precise command used to install the controller, along with the flags and options used
-
if you have more than one instance of the ingress-nginx-controller installed in the same cluster, please provide details for all the instances
-
Current State of the controller:
kubectl describe ingressclasses# kubectl describe ingressclasses Name: nginx Labels: app.kubernetes.io/component=controller app.kubernetes.io/instance=nginx-ingress app.kubernetes.io/managed-by=Helm app.kubernetes.io/name=ingress-nginx app.kubernetes.io/part-of=ingress-nginx app.kubernetes.io/version=1.9.6 helm.sh/chart=ingress-nginx-4.9.1 Annotations: meta.helm.sh/release-name: nginx-ingress meta.helm.sh/release-namespace: myns Controller: k8s.io/ingress-nginx Events: <none>kubectl -n <ingresscontrollernamespace> get all -A -o widekubectl -n <ingresscontrollernamespace> describe po <ingresscontrollerpodname>kubectl -n <ingresscontrollernamespace> describe svc <ingresscontrollerservicename>
-
Current state of ingress object, if applicable:
kubectl -n <appnamespace> get all,ing -o widekubectl -n <appnamespace> describe ing <ingressname>- If applicable, then, your complete and exact curl/grpcurl command (redacted if required) and the reponse to the curl/grpcurl command with the -v flag
-
Others:
- Any other related information like ;
- copy/paste of the snippet (if applicable)
kubectl describe ...of any custom configmap(s) created and in use- Any other related information that may help
- Any other related information like ;
How to reproduce this issue:
Anything else we need to know:
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 4
- Comments: 22 (12 by maintainers)
My problem is that I am using TLS termination at the NLB using https://github.com/kubernetes/ingress-nginx/blob/main/deploy/static/provider/aws/nlb-with-tls-termination/deploy.yaml .
Because an NLB is a layer 4 device it cannot add the
X-Forwarded-Proto: httpsheader when it proxies the unencrypted request to the nginx pod over HTTP (unlike a layer 7 device like an ALB, which can alter headers).So when the request reaches nginx it is over HTTP and without any
X-Forwarded-Protoheader.Consequently nginx proxies it to the actual application service without that header, so the actual application does not know that the original request was made over HTTPS.
It seems very odd to me that a manifest called
nlb-with-tls-terminationwould not solve this problem - perhaps I am missing something?What I tested and found out is that the configMap is for adding new and customized headers but not for changing the default headers.