'Kubernetes nginx ingress controller not forwarding headers with underscores
I'm having a problem where my kubernetes nginx ingress controller is NOT forwarding the headers with underscores in them.
I created a configMap with name my-release-ingress-nginx-controller with the following entry.
enable-underscores-in-headers: "true"
After this i checked the nginx.conf file by describing the nginx ingress controller pod, using this command kubectl exec -it my-release-ingress-nginx-controller-d7648bcc8-6lfxv cat nginx.conf. There i found this underscores_in_headers on;. Even after this toggle, the nginx is still not forwarding the headers with underscores in it.
ConfigMap:
apiVersion: v1
kind: ConfigMap
metadata:
name: my-release-ingress-nginx-controller
namespace: default
data:
enable-underscores-in-headers: "true"
ignore-invalid-headers: "false"
ConfigMap describe:
Name: my-release-ingress-nginx-controller
Namespace: default
Labels: <none>
Annotations:
Data
====
enable-underscores-in-headers:
----
true
ignore-invalid-headers:
----
false
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal CREATE 27s nginx-ingress-controller ConfigMap default/my-release-ingress-nginx-controller
Deployment describe
Args:
/nginx-ingress-controller
--publish-service=default/my-release-ingress-nginx-controller
--election-id=ingress-controller-leader
--ingress-class=nginx
--configmap=default/my-release-ingress-nginx-controller
Ingress describe:
Name: ingress-resource-1
Namespace: default
Address: 172.31.14.220
Default backend: default-http-backend:80 (<error: endpoints "default-http-backend" not found>)
Rules:
Host Path Backends
---- ---- --------
api.dev.com
/ faq-dev:10013 (172.17.0.3:10013)
Annotations: kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/rewrite-target: /
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal UPDATE 3m10s (x2443 over 20h) nginx-ingress-controller Ingress default/ingress-resource-1
Normal UPDATE 2m10s (x2483 over 20h) nginx-ingress-controller Ingress default/ingress-resource-1
PS: I have setup a single node kubernetes cluster using minikube , inside an AWS ec2 server. Also the ingress is configured as a deployment and not a daemonset.The ingress configured is the kubernetes one from this repository - https://github.com/kubernetes/ingress-nginx
Solution 1:[1]
Try this Please
apiVersion: v1
kind: ConfigMap
data:
enable-underscores-in-headers: "true"
ignore-invalid-headers: "false"
metadata:
name: nginx-configuration
namespace: default
and include the same in nginx-ingress-controller-deployment
containers:
- name: nginx-ingress-controller
image: <YOUR NGINX INGRSS IMAGE_NAME>
args:
- /nginx-ingress-controller
- --configmap=$(POD_NAMESPACE)/nginx-configuration
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
Solution 2:[2]
apiVersion: v1
kind: ConfigMap
data:
enable-underscores-in-headers: "true"
metadata:
name: nginx-configuration
namespace: default
enabling underscore in headers
After adding this to the configuration, a rolling restart is required for the config to be picked up.
Solution 3:[3]
create new configmap with the below menifest & delete the pod of nginx controller which basically create new nginx controller with new configmap configuration.
apiVersion: v1
data:
enable-underscores-in-headers: "true"
ignore-invalid-headers: "false"
kind: ConfigMap
metadata:
name: my-release-ingress-nginx-controller
namespace: default
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | rohatgisanat |
| Solution 3 |
