【发布时间】:2022-12-30 21:00:28
【问题描述】:
我已经通过私有 NLB(网络负载平衡器)公开了入口 nginx 控制器。我想在入口 Nginx 上启用主机白名单。
我的用例是允许从 VPC1 到 VPC2 的请求,并且只允许来自 VPC1 的请求通过这个私有 nginx。为此,我使用了下面的注释nginx.ingress.kubernetes.io/whitelist-source-range
我从中得到的问题是 ingress-nginx 没有收到客户端的真实 IP。在做了一些研究后,我发现我必须在 NLB 上启用代理协议。为此,我添加了以下注释和配置。
annotations:
service.beta.kubernetes.io/aws-load-balancer-backend-protocol: tcp
service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout: '60'
service.beta.kubernetes.io/aws-load-balancer-cross-zone-load-balancing-enabled: 'true'
service.beta.kubernetes.io/aws-load-balancer-type: nlb
service.beta.kubernetes.io/aws-load-balancer-internal: "true"
service.beta.kubernetes.io/aws-load-balancer-target-group-attributes: proxy_protocol_v2.enabled=true
metrics:
enabled: true
config:
use-proxy-protocol: "true"
real-ip-header: "proxy_protocol"
准确地说,我只添加了这部分
config:
use-proxy-protocol: "true"
real-ip-header: "proxy_protocol"
service.beta.kubernetes.io/aws-load-balancer-target-group-attributes: proxy_protocol_v2.enabled=true
I've also tried this annotation with same config
service.beta.kubernetes.io/aws-load-balancer-proxy-protocol: "*"
我收到的错误是
broken header: "" while reading PROXY protocol, client: xx.xx.xx.xx
我无法弄清楚我做错了什么。任何帮助是极大的赞赏。
更新 1:
我检查了此注释未启用 aws 控制台代理协议。当我手动启用它时,一切正常。但我不明白为什么这不起作用,是否与我使用的入口 nginx 版本有关?
【问题讨论】:
标签: kubernetes-helm kubernetes-ingress nlb ingress-nginx proxy-protocol