I have installed ngnix
ingress controller on K8 cluster
using helm chart.
helm install --name nginx-ingress stable/nginx-ingress --namespace kube-system
I want to update below values in ngnix.conf
file of ngnix
ingress controller:
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";
}
I have used below 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 }}
Then when I check ngnix.conf using
kubectl exec -it nginx-ingress-controller-b4477bdf7-gwt8v -n kube-system -- cat /etc/nginx/nginx.conf
proxy-connect-timeout
and proxy-read-timeout
do not get updated. It shows default values, and server-snippet also not get added.
Can anyone tell me how to update/add
configuration of ngnix
ingress controller?
Are you still having the problem?
Actually I faced the same issue on proxy-body-size configuration. The value does'nt take effect to the nginx-ingress-controller pod.
I did some researches and found the below solution:
(before) nginx.ingress.kubernetes.io/proxy-body-size: "0"
(after) ingress.kubernetes.io/proxy-body-size: "0"
What I did was omitting the "nginx" in the annotations setting.
I think you may try to configure the annotations as follow:
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"
Hope it works on your environment!
I got the solution to the above problem. I had used
nginx.ingress.kubernetes.io/proxy-connect-timeout: "300s"
instead of
nginx.ingress.kubernetes.io/proxy-connect-timeout: "300"
and
nginx.ingress.kubernetes.io/server-snippet
instead of
nginx.ingress.kubernetes.io/configuration-snippet
Solution :
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 }}