k8s-ingress配置websocket支持

解决办法:
annotations 加入
proxy_set_header Upgrade "websocket";
proxy_set_header Connection "Upgrade";

例子:

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: sx-data-server
  namespace: spot-standard 
  annotations:
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/configuration-snippet: |
       proxy_set_header Upgrade "websocket";
       proxy_set_header Connection "Upgrade";
spec:
  rules:
  - host: sx-data-server.internal.junengcloud.com
    http:
      paths:
      - path: /
        backend:
          serviceName: sx-data-server
          servicePort: 61051

参考文档: https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#configuration-snippet

posted @ 2021-06-11 11:12  klvchen  阅读(1430)  评论(0编辑  收藏  举报