具有代理协议的kubernetes nginx入口以损坏的标头结束

ken*_*ken 5 nginx kubernetes real-ip proxy-protocol

我尝试使用代理协议在Google容器上设置nginx入口(节点端口),以便可以将真实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
Run Code Online (Sandbox Code Playgroud)

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

Jos*_*ker 1

我自己刚刚遇到这个问题。对我来说,我没有负载均衡器(除了我的 nginx 入口),所以我实际上不需要proxy-protocol设置。

然而,我仍然得到127.0.0.1客户端IP。诀窍是我使用的 nginx ingress 版本(0.9.0-beta.5)有一个错误。更新我的容器映像以gcr.io/google_containers/nginx-ingress-controller:0.9.0-beta.8解决问题,我收到了正确的X-Forwarded-For标头。

请注意,更高版本(在撰写本文时最高为 beta.11)仍然存在问题,因此我暂时保留在 beta.8 上。

您可以在https://console.cloud.google.com/gcr/images/google-containers/GLOBAL/nginx-ingress-controller上查看可用版本。

如果您想查看可用的配置选项,请查看https://github.com/kubernetes/ingress/tree/master/controllers/nginx