我有一个 Kubernetes Ingress 设置,如下所示:
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 工作正常,但当身份验证失败(外部身份验证以 HTTP 401 响应)时,似乎没有随响应发送的 CORS 标头。
我尝试将我的外部身份验证服务配置为也响应 CORS 标头,但似乎 nginx 正在删除这些标头。
有谁知道如何设置这个?