我有一个 kubernetes 集群,我在其中使用helm nginx-ingress chart部署了一个 nginx 入口控制器。
我需要向 nginx-controller-pod 中生成的 nginx.conf 文件添加一些自定义配置,并且我看到一个问题,如果我添加一个单行选项,例如proxy-buffer-size: "512k"
我可以在 nginx.conf 中看到这一点文件,一切都按预期工作。
但是,如果我尝试添加一个片段来完成同样的事情:
location-snippet: |
proxy_buffer_size "512k";
好像这被 nginx.conf 文件忽略了,并且proxy_buffer_size
设置保持在它的默认值。
我需要能够添加和覆盖http-snippet
,但无论我尝试将它们添加到 ConfigMap 还是作为 Ingress.yaml 文件中的注释,它们总是被忽略。server-snippet
location-snippet
我的入口 yaml 文件:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: my-ingress
annotations:
kubernetes.io/ingress.class: nginx
ingress.kubernetes.io/ssl-redirect: "true"
ingress.kubernetes.io/secure-backends: "true"
ingress.kubernetes.io/force-ssl-redirect: "true"
ingress.kubernetes.io/location-snippet: |
proxy_buffer_size 512k; --This does not update the nginx.conf
spec:
tls:
- hosts:
- my.app.co.uk
secretName: tls-secret
rules:
- host: my.app.co.uk
http:
paths:
- path: /
backend:
serviceName: myappweb-service
servicePort: 80
我的 nginx 配置图:
apiVersion: v1
kind: ConfigMap
metadata:
labels:
app: nginx-ingress
chart: nginx-ingress-0.28.3
component: controller
heritage: Tiller
release: nginx-ingress
name: nginx-ingress-controller
namespace: default
data:
proxy-buffer-size: "512k" -- this works and updates the nginx.conf
location-snippet: |
proxy_buffers 4 512k; -- this does not update the nginx.conf
server-snippet: | -- this does not update the nginx.conf
location /messagehub {
proxy_set_header Upgrade $http_upgrade;
proxy_http_version 1.1;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_set_header Connection "upgrade";
proxy_cache_bypass $http_upgrade;
}