I want to edit my Nginx.conf
file present inside Nginx controller pod in AKS, but the edit command is not working using the exec command, is there any way else I could edit my nginx.conf
.
the command which I tried:
kubectl exec -it nginx-nginx-ingress-controller -n nginx -- cat /etc/nginx/nginx.conf
As mentioned by CrowDev, it's not good practice to update the config of Nginx controller like that.
Nginx controller is the backend of the ingress you can use the config map to update the configuration of the Nginx controller and redeploy the pod of the controller.
Some of the Nginx controller config could be also overwritten using the ingress config and annotation inside it.
You can read more about annotation here : https://docs.nginx.com/nginx-ingress-controller/configuration/ingress-resources/advanced-configuration-with-annotations/
Update :
You can separate out different ingress by their name. if you want to manage different configs or headers you need to separate out ingress for managing different configs.
Example :
ingress : 1
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress-one
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/rewrite-target: /
nginx.ingress.kubernetes.io/proxy-read-timeout: "3600"
spec:
rules:
- http:
paths:
- path: /one
pathType: Prefix
backend:
service:
name: one
port:
number: 80
ingress : 2
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress-two
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- http:
paths:
- path: /two
pathType: Prefix
backend:
service:
name: two
port:
number: 80
now nginx.ingress.kubernetes.io/proxy-read-timeout: "3600"
will get apply to only one ingress or service.