Add HTTP headers while running Traefik as Ingress controller

3/8/2018

I have an application running in K8S, with Traefik as load balancer as an Ingress controller. While I ca setup easily Traefik for redirection, I need to add specific HTTP headers to all queries going through Traefik.

Is there any way to do this with Traefik?

Cheers, Olivier

-- Olivier
kubernetes-ingress
traefik

1 Answer

3/8/2018

Yes. You need to add specific annotation from K8S in the YAML for Ingress:

ingress.kubernetes.io/custom-request-headers: X-ProxyScheme:HERE_IS_MY_SCHEME||X-ProxyHost:HERE_IS_MY_HOST
ingress.kubernetes.io/proxy-headers: X-ProxyScheme,X-ProxyHost,X-ProxyPort

As shown, if you need multiple custom headers, you must pipe them with ||. And you need to "enable" them with annotation ingress.kubernetes.io/proxy-headers

Cheers, Olivier

-- Olivier
Source: StackOverflow