【发布时间】:2022-11-30 17:16:00
【问题描述】:
我在 AWS EKS 上部署了 NGINX Plus Ingress 控制器,在入口前我部署了一个网络负载均衡器 (NLB)。我已经在 AWS Cognito 中设置了一个用户池,并根据此处的说明在 NGINX 中设置了 JWT 验证https://docs.nginx.com/nginx/admin-guide/security-controls/configuring-jwt-authentication/#getting-jwks-from-subrequest。
auth_jwt "closed";
auth_jwt_type signed;
auth_jwt_key_cache 1h;
auth_jwt_key_request /jwks_uri;
...
location = /jwks_uri {
internal;
proxy_pass https://cognito-idp.{region}.amazonaws.com/{userPoolId}/.well-known/jwks.json;
}
我尝试了各种代理设置 - 从增加超时、设置 proxy_method GET、剥离标头,但似乎没有任何帮助。我还通过添加将子请求部分从等式中删除
location /jwks_uri {
proxy_pass https://cognito-idp.{region}.amazonaws.com/{userPoolId}/.well-known/jwks.json;
}
那里的请求成功了,所以我不认为这是防火墙问题。
当我在授权标头中使用 Cognito 发出的有效 JWT 发出请求时,如果我等待超过一分钟,我最终会收到 502 响应。在 NGINX 日志中我可以看到
2022/11/24 08:47:55 [warn] 56#56: *19 upstream server temporarily disabled while reading response header from upstream, client: 10.10.20.57, server: <server>, request: "POST /graphql HTTP/1.1", subrequest: "/jwks_uri", upstream: <jwks-uri>", host: <host
这似乎发生在 NGINX 尝试子请求从 AWS 从 https://cognito-idp.{region}.amazonaws.com/{userPoolId}/.well-known/jwks.json 获取 jwks 密钥时
【问题讨论】:
标签: nginx amazon-eks nlb