Ingress-nginx 配置 websocket 支持

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: api
annotations:
# 配置ingress 使用 nginx
kubernetes.io/ingress.class: nginx
# 配置websocket 需要的配置
nginx.ingress.kubernetes.io/configuration-snippet: |
proxy_set_header Upgrade "websocket";
proxy_set_header Connection "Upgrade";
spec:
rules:
- host: api.xxx.com
http:
# webSocket config
- path: /middle/(.*)/ws
pathType: Prefix
backend:
service:
name: prod-xxxxxx
port:
number: 80
1
kubectl apply -f ingress-name.yaml