我已经通过私有 NLB(网络负载均衡器)公开了入口 nginx 控制器。我想在入口 Nginx 上启用主机白名单。
我的用例是允许从 VPC1 到 VPC2 的请求,并且只应允许来自 VPC1 的请求通过此私有 nginx。为此,我使用了下面的注释
nginx.ingress.kubernetes.io/whitelist-source-range
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 控制台代理协议。当我手动启用它时,一切正常。但我不明白为什么这不起作用,这与我使用的 ingress nginx 版本有关吗?
为了启用代理协议并使该注释起作用
service.beta.kubernetes.io/aws-load-balancer-target-group-attributes: proxy_protocol_v2.enabled=true
service.beta.kubernetes.io/aws-load-balancer-type: nlb
kubernetes 使用自己的负载均衡器控制器,但不支持此注释。service.beta.kubernetes.io/aws-load-balancer-type: external
service.beta.kubernetes.io/aws-load-balancer-nlb-target-type: instance/ip (on the basis of your use case).
已接受的答案需要更新。现在需要 aws-loadbalancer-controller。