Traefik : Add Custom Header Only for specific files

11/20/2018

UPDATE: ATM this is not possible via traefik. I have openend an issue : https://github.com/containous/traefik/issues/4228

I want to add cache-control headers to files having the Content/Type application/json and image/png.

ATM the moment the way to go forward is to use custom-response-headers.

kind: Ingress
metadata:
  annotations:
    ingress.kubernetes.io/custom-response-headers: Cache-Control: private || Cache-Control: max-age=31536000

Below is the path configuration :

spec:
  rules:
  - http:
      paths:
      - backend:
          serviceName: myabc
          servicePort: 443
        path: /myabc
      - backend:
          serviceName: myxyz
          servicePort: 443
        path: /myxyz

I only want the custom headers to be applied when the static files like .js or .png are requested.

Any pointer on how to move forward? Is this possible via traefik?

-- Syed Osama Maruf
kubernetes
traefik
traefik-ingress

0 Answers