Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cors-allow-origin - use more than 1 URL #477

Closed
hAh0L13 opened this issue Dec 11, 2019 · 9 comments
Closed

cors-allow-origin - use more than 1 URL #477

hAh0L13 opened this issue Dec 11, 2019 · 9 comments

Comments

@hAh0L13
Copy link

hAh0L13 commented Dec 11, 2019

Hello all.

We use HAProxy-ingress 0.7.2 in our cluster (OKD, openshift)

Can I use two or more URLs in ingress annotation ingress.kubernetes.io/cors-allow-origin ?

If I adding two annotations, it use last applied. If I adding list of URLs delimited by comma, controller switch header to any - "*"

Docs didn't cover this case

@jcmoraisjr
Copy link
Owner

Hi, from this mdn doc:

Access-Control-Allow-Origin specifies either a single origin, which tells browsers to allow that origin to access the resource; or else — for requests without credentials — the "*" wildcard, to tell browsers to allow any origin to access the resource.

So it sounds you can only use one origin or a wildcard * which the current implementation already supports.

@hAh0L13
Copy link
Author

hAh0L13 commented Dec 12, 2019

Hi. Big thanks for this. Should have been more attentive.Thanks for link

@hAh0L13 hAh0L13 closed this as completed Dec 12, 2019
@maxisam
Copy link

maxisam commented May 26, 2021

FYI, nginx is going to support it. They are fixing a bug now

@hAh0L13
Copy link
Author

hAh0L13 commented May 26, 2021

FYI, nginx is going to support it. They are fixing a bug now

I would like a link to the confirmation of this

@maxisam
Copy link

maxisam commented May 26, 2021

@hAh0L13 can't believe I forgot to paste the link kubernetes/ingress-nginx#5496

@jcmoraisjr
Copy link
Owner

How one would implement this? It's technically pretty simple but it's apparently unsupported?

https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS/Errors/CORSMultipleAllowOriginNotAllowed

It seems to me that I cannot add more than one header and this one should have one origin or a wildcard.

@hAh0L13
Copy link
Author

hAh0L13 commented May 27, 2021

It seems to me that I cannot add more than one header and this one should have one origin or a wildcard.

It looks like the solution is in a conditional block where CORS headers are configured on the fly based on a compare origin domain with list of allowed domains.
kubernetes/ingress-nginx#5496 (comment)
ingress-nginx supports configurations snippets that allow this

@jcmoraisjr
Copy link
Owner

Ah sure, a dynamic response based on the request. It seems promising, will have a look on this.

@jcmoraisjr
Copy link
Owner

Just to let you know added to v0.13-beta.1, doc here. Ping here is this doesn't work as you expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants