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