使用注释nginx.ingress.kubernetes.io/server-snippet
可以在服务器配置块中添加自定义配置。
每个主机只能使用此注释一次。
例子1:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/server-snippet: |
set $agentflag 0;
if ($http_user_agent ~* "(Mobile)" ){
set $agentflag 1;
}
if ( $agentflag = 1 ) {
return 301 https://m.example.com;
}
例子2:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/stream-snippet: |
server {
listen 8000;
proxy_pass 127.0.0.1:80;
}
例子3:
nginx.ingress.kubernetes.io/auth-url: http://foo.com/external-auth
nginx.ingress.kubernetes.io/auth-snippet: |
proxy_set_header Foo-Header 42;
修改阿里云ingress nginx日志字段
https://www.modb.pro/db/406812
参考阿里云片段高级用法
https://help.aliyun.com/document_detail/86533.html