繁体   English   中英

Kubernetes nginx ingress代理传递给websocket

[英]Kubernetes nginx ingress proxy pass to websocket

我们正在使用独角兽和websocket运行rails应用程序。 我们正在使用AWS ELB,因为入口SSL终止于ELB并将流量转发到应用程序。

Nginx ingress将流量路由到端口8080上运行unicorn / puma的web应用程序。

应用程序工作,但我们的websocket响应200而不是101.我们已启用CORS并在入口中使用所需的注释。

这是用于入口控制器服务的注释

service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http
service.beta.kubernetes.io/aws-load-balancer-proxy-protocol: '*'
service.beta.kubernetes.io/aws-load-balancer-ssl-cert::arn:aws:iam::xxx:server-certificate/staging
service.beta.kubernetes.io/aws-load-balancer-ssl-ports: https

当我们使用aws loadbalancer协议作为tcp并将负载均衡器端口作为443时,它在无限重定向循环上失败。

以下是入口中使用的注释:

nginx.ingress.kubernetes.io/service-upstream: true      
nginx.ingress.kubernetes.io/cors-allow-methods: "PUT, GET, POST, OPTIONS"
nginx.ingress.kubernetes.io/cors-allow-headers: "DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type"
nginx.ingress.kubernetes.io/cors-allow-origin: "*"
nginx.ingress.kubernetes.io/cors-allow-credentials: "true"
ingress.kubernetes.io/force-ssl-redirect: "true"

我们之前使用的没有入口的示例nginx配置就在这里

如何让websockets与AWS ELB一起使用nginx入口控制器?

没有CORS可以尝试吗?

握手的一部分是客户端必须至少发送以下这些标头:

Sec-WebSocket-Key
Sec-WebSocket-Version

也许别的东西。 请查看https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_servers#The_WebSocket_Handshake

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM