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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM