NGINX模板位于 /etc/nginx/template/nginx.tmpl
文件中.
使用 Volume 讲自定义模板变为可能. 这包括使用 Configmap 作为模板的源文件
volumeMounts:
- mountPath: /etc/nginx/template
name: nginx-template-volume
readOnly: true
volumes:
- name: nginx-template-volume
configMap:
name: nginx-template
items:
- key: nginx.tmpl
path: nginx.tmpl
请注意,模板已绑定到Go代码。 不要在变量中更改名称 $cfg
.
有关模板语法的更多信息,请检查 Go template package. 除了Go软件包提供的内置功能之外,还可以使用以下功能:
- empty: 如果指定的参数(字符串)为空,则返回true
- contains: strings.Contains
- hasPrefix: strings.HasPrefix
- hasSuffix: strings.HasSuffix
- toUpper: strings.ToUpper
- toLower: strings.ToLower
- quote: 将字符串用双引号引起来
- buildLocation: 帮助在每个服务器中构建nginx location部分
- buildProxyPass: 建立反向代理配置
- buildRateLimit: 如果包含速率限制注释,则有助于在位置内建立限制区域
TODO:
- buildAuthLocation:
- buildAuthResponseHeaders:
- buildResolvers:
- buildDenyVariable:
- buildUpstreamName:
- buildForwardedFor:
- buildAuthSignURL:
- buildNextUpstream:
- filterRateLimits:
- formatIP:
- getenv:
- getIngressInformation:
- serverConfig:
- isLocationAllowed:
- isValidClientBodyBufferSize: