Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enable underscores in headers on Azure ingress

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.

like image 616
user1002065 Avatar asked Jan 30 '23 07:01

user1002065


2 Answers

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
kind: ConfigMap
metadata:
  name: nginx-configuration
  namespace: ingress-nginx
  labels:
    app: ingress-nginx
data:
  enable-underscores-in-headers: "true"

kubectl apply -f configmap.yml

enter image description here

like image 126
kartik Avatar answered Jan 31 '23 22:01

kartik


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?

like image 30
vittore Avatar answered Jan 31 '23 20:01

vittore