我已使用头盔图表在ngnix
上安装了K8 cluster
入口控制器。
helm install --name nginx-ingress stable/nginx-ingress --namespace kube-system
我想更新ngnix.conf
入口控制器的ngnix
文件中的以下值:
1. proxy-connect-timeout
2. proxy-read-timeout
3. location
{
add_header "Cache-Control" "max-age=0, no-cache, no-store, must-revalidate";
add_header "Pragma" "no-cache";
add_header "Expires" "-1";
}
我在ingress.yaml下面使用了
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: test-iningress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
nginx.ingress.kubernetes.io/proxy-connect-timeout: "300s"
nginx.ingress.kubernetes.io/proxy-read-timeout: "300s"
nginx.ingress.kubernetes.io/client-max-body-size: "0"
nginx.ingress.kubernetes.io/server-snippet: |
location / {
add_header "Cache-Control" "max-age=0, no-cache, no-store, must-revalidate";
add_header "Pragma" "no-cache";
add_header "Expires" "-1";
}
spec:
rules:
- host: {{ .Values.ingress.hosts }}
http:
paths:
- path: /ui
backend:
serviceName: sift-ui-service
servicePort: {{ .Values.service.sift_ui.port }}
然后当我使用检查ngnix.conf时
kubectl exec -it nginx-ingress-controller-b4477bdf7-gwt8v -n kube-system -- cat /etc/nginx/nginx.conf
proxy-connect-timeout
和proxy-read-timeout
未更新。它显示默认值,也不会添加服务器代码段。
谁能告诉我如何update/add
配置ngnix
入口控制器?
答案 0 :(得分:0)
您还有问题吗?
实际上,我在proxy-body-size配置上也遇到了同样的问题。该值对nginx-ingress-controller pod无效。
我做了一些研究,找到了以下解决方案:
(before) nginx.ingress.kubernetes.io/proxy-body-size: "0"
(after) ingress.kubernetes.io/proxy-body-size: "0"
我所做的是在注释设置中省略了“ nginx”。
我认为您可以尝试按以下方式配置注释:
metadata:
name: test-iningress
annotations:
ingress.kubernetes.io/rewrite-target: /
ingress.kubernetes.io/proxy-connect-timeout: "300s"
ingress.kubernetes.io/proxy-read-timeout: "300s"
ingress.kubernetes.io/client-max-body-size: "0"
希望它在您的环境中有效!
答案 1 :(得分:0)
我已经解决了上述问题。 我用过
nginx.ingress.kubernetes.io/proxy-connect-timeout: "300s"
代替
nginx.ingress.kubernetes.io/proxy-connect-timeout: "300"
和
nginx.ingress.kubernetes.io/server-snippet
代替
nginx.ingress.kubernetes.io/configuration-snippet
解决方案:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: test-iningress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
nginx.ingress.kubernetes.io/proxy-connect-timeout: "300"
nginx.ingress.kubernetes.io/proxy-read-timeout: "300"
nginx.ingress.kubernetes.io/proxy-body-size: "0"
nginx.ingress.kubernetes.io/client-max-body-size: "0"
nginx.ingress.kubernetes.io/configuration-snippet: |
add_header "Cache-Control" "max-age=0, no-cache, no-store, must-revalidate";
add_header "Pragma" "no-cache";
add_header "Expires" "-1";
spec:
rules:
- host: {{ .Values.ingress.hosts }}
http:
paths:
- path: /ui
backend:
serviceName: sift-ui-service
servicePort: {{ .Values.service.sift_ui.port }}