kubernetes-ingress
kubernetes-ingress copied to clipboard
added custom annotation to ingress for CORS
Proposed changes
support CORS by providing a custom annotation to Ingress', which then is reflected in the NGINX ingress configuration.
By adding the custom annotation "custom.nginx.org/cors-allow-origin" to an ingress, with the value of the target server (i.e. "https://sample.server.org/"), the according NGINX ingress configuration is created in the "server {}" section:
# replace Access-Control-Allow-Origin header
proxy_hide_header "Access-Control-Allow-Origin";
add_header Access-Control-Allow-Origin "https://sample.server.org";
Hiding the original header values proved to be required, as else the browser might complain about multiple set values.
Checklist
Before creating a PR, run through this checklist and mark each as complete.
- [x] I have read the CONTRIBUTING doc
- [x] I have added tests that prove my fix is effective or that my feature works
- [x] I have checked that all unit tests pass after adding my changes
- [x] I have updated necessary documentation
- [x] I have rebased my branch onto main
- [x] I will ensure my PR is targeting the main branch and pulling from my branch from my own fork