我最近遇到了 nlb 问题,在 lb 上使用带有 https 终止的 nlb 在 EKS 上使用重定向 http=>https 和 ingress-nginx 是一次冒险。
现在,我想将 X-Forwarded header 传递给 pod,但这会破坏 http=>https 重定向,我在 http 请求上得到 400。
在服务上,我尝试把服务放到http或者tcp协议(protocol)上,都是一样的。
向服务添加 service.beta.kubernetes.io/aws-load-balancer-proxy-protocol: "*"
header ,在所有目标上激活代理协议(protocol) v2,并激活 use-proxy-protocol: 'true'
在 nginx 的 configmap 中用 308 重定向打破了 http-snippet:
http-snippet: |
server {
listen 2443;
return 308 https://$host$request_uri;
}
有没有人有办法让它可以使用 nlb 以及所有好的 header 和重定向工作?
编辑 在评论请求添加完整的工作配置
apiVersion: v1
kind: ConfigMap
metadata:
labels:
app.kubernetes.io/version: 0.41.0
app.kubernetes.io/component: controller
name: ingress-nginx-controller
data:
http-snippet: |
server {
listen 2443 proxy_protocol;
return 308 https://$host$request_uri;
}
proxy-real-ip-cidr: 10.4.0.0/16
use-forwarded-headers: 'true'
use-proxy-protocol: 'true'
compute-full-forwarded-for: 'true'
最佳答案
为了结束我们与@night-gold 的评论讨论,要使 NGINX 接受代理协议(protocol),您必须在 listen 指令中特别提及:
http {
#...
server {
listen 80 proxy_protocol;
listen 443 ssl proxy_protocol;
#...
}
}
查看 NGINX guide了解更多。
关于amazon-ec2 - 带 https 重定向的 EKS ingress-nginx 和 NLB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65613674/