Search code examples
kuberneteskubernetes-ingressnginx-ingress

kubernetes ingress controller not forwarding request headers


I am working on a kubernetes cluster and problem faced is:

From UI/browser, I can see it is sending a request header called "request_id" please refer to image:

enter image description here

But while checking on backend it is unavailable. While searching through internet, I could see that people are talking about adding following entry to Ingress object:

nginx.ingress.kubernetes.io/configuration-snippet: |
      proxy_set_header request_id "$req_id";

But it is generating a new value for this and not passing value submitted by browser.

Any ideas, what might be missing here?


Solution

  • Basically, ingress-nginx-controller drops any request headers that contains "_" in them. You can find various threads which discuss this issue like,

    Why HTTP servers forbid underscores in HTTP header names

    So, I just enabled ingress controller to pass such request headers. This can be done by adding following entry to configmap "nginx-configuration"

    data:
      enable-underscores-in-headers: "true"
    

    IMO, this is a much clean solution as there could be many applications that might use "_" in request headers.