nginx-ingress用注解设置wss,keepalive-timeout等
ingress-nginx用注解设置wss,keepalive-timeout通过ginx.ingress.kubernetes.io/configuration-snippet配置nginx.ingress.kubernetes.io/configuration-snippet: |-proxy_set_header Upgrade "websocket";proxy_set_header Co
·
nginx-ingress
用注解设置wss,keepalive-timeout
通过nginx.ingress.kubernetes.io/configuration-snippet
配置
nginx.ingress.kubernetes.io/configuration-snippet: |-
proxy_set_header Upgrade "websocket";
proxy_set_header Connection "Upgrade";
nginx.ingress.kubernetes.io/backend-protocol
配置后端协议
例:
nginx.ingress.kubernetes.io/backend-protocol: FCGI
#添加特殊配置片段
nginx.ingress.kubernetes.io/configuration-snippet: keepalive_timeout 0;
#关闭ssl强制跳转
nginx.ingress.kubernetes.io/ssl-redirect: "false"
nginx.ingress.kubernetes.io/enable-cors: "true"
nginx.ingress.kubernetes.io/enable-modsecurity: "true"
nginx.ingress.kubernetes.io/enable-owasp-core-rules: "true"
nginx.ingress.kubernetes.io/server-snippet: keepalive_timeout 0;
nginx.ingress.kubernetes.io/ssl-redirect: "false"
配置重写规则
$ echo '
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$2
name: rewrite
namespace: default
spec:
rules:
- host: rewrite.bar.com
http:
paths:
- backend:
serviceName: http-svc
servicePort: 80
path: /something(/|$)(.*)
' | kubectl create -f -
在此入口定义中,捕获的任何字符(.*)都将分配给占位符$2,然后将其用作rewrite-target注释中的参数。
例如,上面的入口定义将导致以下重写:
rewrite.bar.com/something 重写为 rewrite.bar.com/
rewrite.bar.com/something/ 重写为 rewrite.bar.com/
rewrite.bar.com/something/new 重写为 rewrite.bar.com/new
ingress-nginx官网说明链接: link.
更多推荐
已为社区贡献4条内容
所有评论(0)