Traefik Ingress Kubernetes - Conditional CORS Access Control Allow Origin

4/15/2019

I have two frontend applications that access the same API gateway: example.com and admin.example.com

I'm using Traefik as my ingress controller. I currently have the following annotation in my k8s ingress configuration:

ingress.kubernetes.io/custom-response-headers: Access-Control-Allow-Origin:https://example.com || Access-Control-Allow-Methods:POST, GET, HEAD, OPTIONS, PUT, DELETE

I also would like to handle https://admin.example.com within the same block. Is there a way that I can setup a conditional expression here dependant on the origin URL that the traffic is originating from? Access-Control-Allow-Origin: * is not acceptable for my usecase (browsers complain).

-- Jonathan Eustace
kubernetes
traefik
traefik-ingress

0 Answers