使用代理协议的kubernetes nginx ingress最终破坏了标题

我尝试使用代理协议在google容器上设置nginx ingress(nodeport),以便真正的ip可以转发到后端服务,但最终会出现断页.

2017/02/05 13:48:52 [error] 18#18: *2 broken header: "�����~��]H�k��m[|����I��iv.�{y��Z �嵦v�Ȭq���2Iu4P�z;�    o$�s����"���+�/�,�0̨̩����/" while reading PROXY protocol, client: 10.50.0.1, server: 0.0.0.0:443

如果没有代理协议,事情就会很好.根据https://blog.mythic-beasts.com/2016/05/09/proxy-protocol-nginx-broken-header/,这是由于协议v2被使用(二进制),但nginx只能说v1.有什么建议吗?

最佳答案 GKE:使用kubernetes v1.6源默认保留ip,可以在x-real-ip下的头文件中找到,而无需设置任何额外的nginx配置.

AWS:可以通过将此添加到注释来保留源IP

apiVersion: v1
kind: Service
metadata:
  name: nginx-ingress
  namespace: nginx-ingress
  annotations:
    service.beta.kubernetes.io/aws-load-balancer-proxy-protocol: '*'
  labels:
    app: nginx-ingress

查看此链接
https://github.com/kubernetes/ingress/tree/master/examples/aws/nginx

点赞