I have a problem with headers not forwarded into my services, I am not sure how support for Ingress was added, however I have the following Ingress service:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: my-ingress
annotations:
ingress.kubernetes.io/rewrite-target: /
"nginx.org/proxy-pass-headers": "custom_header"
spec:
rules:
- host: myingress.westus.cloudapp.azure.com
http:
paths:
- path: /service1
backend:
serviceName: service1
servicePort: 8080
However, my custom_header will not be forwarded. In nginx I set underscores_in_headers:
underscores_in_headers on;
How can I add this configuration into my ingress nginx service?
Thanks.
Whenever you install Nginx Ingress in Kubernetes weather from Helm Or manually, It always creates Controllers with it. Controllers are the primary containers that handles all the routing. These controller pods are defined in the deployments that resides in the Kube-System Namespace. This deployment is attached with a ConfigMap that as well reside in the Kube-System. Deployment that have Nginx Ingress Controllers definition.
Default Config Map that is Connected to Ingress Deployment.
Now all you have to do is to add your configuration in this Config Map file. Altered/Edited Config Map.
I've just changed "true" instead of "on", for nginx ingress controller , and workd for me . As mentioned here : https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/configmap/
apiVersion: v1
data: enable-underscores-in-headers: "true"
kind: ConfigMap
metadata:
name: nginx-configuration
namespace: ingress-nginx
labels:
app: ingress-nginx
kubectl apply -f configmap.yml
According to ingress configmap spec you can use this header directly in configspec e.g.:
apiVersion: v1
data:
enable-underscores-in-headers: "on"
kind: ConfigMap
metadata:
name: nginx-configuration
namespace: ingress-nginx
labels:
app: ingress-nginx
kubectl apply -f configmap.yml
Also there is an example of setting custom headers Did you try that?