WebSocket handshake: Unexpected response code: 400 in kubernetes-ingress
As stated in the nginx-ingress documentation, to proxy WebSocket traffic you should use annotation with the name of websocket service. Don't forget to use quotes:
nginx.org/websocket-services: "service1[,service2,...]"
In this example from the documentation, WebSocket is enabled only for one of three services (ws-svc
):
apiVersion: extensions/v1beta1kind: Ingressmetadata: name: cafe-ingress annotations: nginx.org/websocket-services: "ws-svc"spec: rules: - host: cafe.example.com http: paths: - path: /tea backend: serviceName: tea-svc servicePort: 80 - path: /coffee backend: serviceName: coffee-svc servicePort: 80 - path: /ws backend: serviceName: ws-svc servicePort: 8008
try add annotationnginx.ingress.kubernetes.io/upstream-hash-by: "$arg_token"
You want to add the nginx.org/websocket-services
annotation to your ingress resource definition. That, in turn, tells nginx to support websockets (which I believe has to do with the Upgrade/Connection headers?).
apiVersion: extensions/v1beta1kind: Ingressmetadata: name: websocket-producer-cdph annotations: nginx.org/websocket-services: "websocket-producer-cdph"spec: rules: - host: some.domain.com http: paths: - path: / backend: serviceName: websocket-producer-cdph servicePort: 8183