Nginx ingress controller websocket support

后端 未结 1 1643
灰色年华
灰色年华 2021-01-02 18:52

Recently I\'ve been working on a toy app using Kubernetes. Part of the app is a web server that needs to support WebSockets. Currently, I\'m using port-forwarding to access

相关标签:
1条回答
  • 2021-01-02 19:47

    From looking at the nginx ingress controller docs and the nginx docs you probably need something like this as an annotation on your Kubernetes Ingress:

    nginx.ingress.kubernetes.io/configuration-snippet: |
       proxy_http_version 1.1;
       proxy_set_header Upgrade "websocket";
       proxy_set_header Connection "Upgrade";
    

    Note that once you add that annotation all of your Ingress rules will have that snippet in the location block in your nginx configs. So if you want to ignore it for other rules you will have to create a separate Kubernetes Ingress.

    EDIT:

    As per the gist and the Nginx ingress docs

    0 讨论(0)
提交回复
热议问题