<p>It's currently possible to allow a single domain or subdomain but I would like to allow multiple origins. I have tried many things like adding headers with snipets but had no success.</p>
<p>This is my current ingress configuration:</p>
<pre><code>kind: Ingress
apiVersion: extensions/v1beta1
metadata:
  name: nginx-ingress
  namespace: default
  selfLink: /apis/extensions/v1beta1/namespaces/default/ingresses/nginx-ingress
  uid: adcd75ab-b44b-420c-874e-abcfd1059592
  resourceVersion: '259992616'
  generation: 7
  creationTimestamp: '2020-06-10T12:15:18Z'
  annotations:
    cert-manager.io/cluster-issuer: letsencrypt-prod
    ingress.kubernetes.io/enable-cors: 'true'
    ingress.kubernetes.io/force-ssl-redirect: 'true'
    kubernetes.io/ingress.class: nginx
    kubernetes.io/tls-acme: 'true'
    nginx.ingress.kubernetes.io/cors-allow-credentials: 'true'
    nginx.ingress.kubernetes.io/cors-allow-headers: 'Authorization, X-Requested-With, Content-Type'
    nginx.ingress.kubernetes.io/cors-allow-methods: 'GET, PUT, POST, DELETE, HEAD, OPTIONS'
    nginx.ingress.kubernetes.io/cors-allow-origin: 'https://example.com'
    nginx.ingress.kubernetes.io/enable-cors: 'true'
    nginx.ingress.kubernetes.io/rewrite-target: /
    nginx.ingress.kubernetes.io/secure-backends: 'true'
</code></pre>
<p>I also would like to extend the cors-allow-origin like:</p>
<pre><code>nginx.ingress.kubernetes.io/cors-allow-origin: 'https://example.com, https://otherexample.com'
</code></pre>
<p>Is it possible to allow multiple domains in other ways?</p>

Vural
<p>Ingress-nginx doesn’t support CORS with multiple origins.</p>
<p>However, you can try to use annotation: <strong>nginx.ingress.kubernetes.io/configuration-snippet</strong></p>
<pre><code>nginx.ingress.kubernetes.io/configuration-snippet: |
  if ($http_origin ~* &quot;^https?://((?:exactmatch\.com)|(?:regexmatch\.com))$&quot;) {
    add_header &quot;Access-Control-Allow-Origin&quot; &quot;$http_origin&quot; always;
    add_header &quot;Access-Control-Allow-Methods&quot; &quot;GET, PUT, POST, OPTIONS&quot; always;
    add_header &quot;Access-Control-Allow-Headers&quot; &quot;DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization&quot; always;
    add_header &quot;Access-Control-Expose-Headers&quot; &quot;Content-Length,Content-Range&quot; always;
  }
</code></pre>
<p>Here to find more information <a href="https://github.com/kubernetes/ingress-nginx/issues/5496" rel="nofollow noreferrer">ingress nginx issues</a>.</p>
