I have a Kubernetes Ingress setup as this:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: api
namespace: staging
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/rewrite-target: /hello/$1
nginx.ingress.kubernetes.io/enable-cors: "true"
nginx.ingress.kubernetes.io/auth-url: http://external-auth/authenticate
nginx.ingress.kubernetes.io/auth-response-headers: X-MemberId
nginx.ingress.kubernetes.io/auth-method: GET
nginx.ingress.kubernetes.io/configuration-snippet: |
error_page 401 = @unauthorized;
nginx.ingress.kubernetes.io/server-snippet: |
location @unauthorized {
return 401 "Unauthorized";
}
spec:
...
CORS works fine when requests are successfully authenticated, but when authentication fails (the external-auth responds with HTTP 401) there seems to be no CORS headers sent with the response.
I have tried configuring my external auth service to also respond with CORS headers, but it seems that nginx is dropping these headers.
Does anyone know how to set this up?