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