George Thomas
George Thomas

Reputation: 4586

Ingress controller annotation to supports multiple cors origin

I have a kubernetes cluster with several services deployed in it, now my angular app is trying to connect to the microservice through the network load balancer url connected to ingress, now in the CORS annotation i want to specify a set of domains who can access the services

I have a admin portal angular app and user portal angular app, both have different domains , both want to connect to the service in the kubernetes cluster.

Suppose how could we specify www.angular1.com and www.angular2.com in the ingress cors annotation

Right now my configuration allows all origins,

nginx.ingress.kubernetes.io/cors-allow-origin: "*"

Now i want to specify something like

nginx.ingress.kubernetes.io/cors-allow-origin: www.angular1.com,www.angular2.com

What is the proper standard.

Upvotes: 0

Views: 1639

Answers (1)

John
John

Reputation: 1285

nginx.ingress.kubernetes.io/cors-allow-origin: Controls what's the accepted Origin for CORS.

This is a single field value

kubernetes.github.io - https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#enable-cors

There is a GitHub issue open requesting support for this feature: https://github.com/kubernetes/ingress-nginx/issues/5496

You can see some users in the issue have used nginx.ingress.kubernetes.io/configuration-snippet to configure cors like you would in a nginx config file.

If you have control of the cluster, you could also consider changing ingress controllers. Emissary-ingress and Traefik are two I know of that support multiple origins, I'm sure there are others as well.

Upvotes: 1

Related Questions