I need to specify random port for nginx.ingress.kubernetes.io/cors-allow-origin
My configuration is:
annotations:
nginx.ingress.kubernetes.io/enable-cors: "true"
nginx.ingress.kubernetes.io/cors-allow-methods: "GET, POST, PUT, DELETE, OPTIONS"
nginx.ingress.kubernetes.io/cors-allow-credentials: "true"
nginx.ingress.kubernetes.io/cors-max-age: 3600
nginx.ingress.kubernetes.io/cors-allow-headers: "Cache-Control,Content-Type,Authorization,Origin,Accept"
nginx.ingress.kubernetes.io/configuration-snippet: |
if ($http_origin ~* (^(http://localhost(:\d+)?)$|^(https://(.+\.)?mydomain.com)$)) {
more_set_headers "Access-Control-Allow-Origin: $http_origin";
}
But Access-Control-Allow-Origin value overrided for requests and it shows ‘*’
btw: nginx.ingress.kubernetes.io/cors-allow-origin by default eq ‘*’ ( ingress-nginx/annotations.md at main · kubernetes/ingress-nginx · GitHub)
Can I set allowed origin using Access-Control-Allow-Origin ?
Cluster information:
Kubernetes version: 1.24
Installation method: Helm
Image: GitHub - kubernetes/ingress-nginx: Ingress-NGINX Controller for Kubernetes
Version: v1.5.1