In nginx, I've got some configuration like this:
location /admingateway/ {
proxy_pass http://localhost:8001/admingateway/;
proxy_set_header Host $host:$proxy_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Via "nginx";
}
My question is how can I configure the same behavior in my ingress yaml for the 4 header settings?
CodePudding user response:
You must use the
nginx.ingress.kubernetes.io/server-snippet
Annotation in order to add custom Nginx configuration
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: nginxconfigsnippet
annotations:
nginx.ingress.kubernetes.io/server-snippet: |
location /admingateway/ {
proxy_pass http://localhost:8001/admingateway/;
proxy_set_header Host $host:$proxy_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Via "nginx";
}
spec:
rules:
- http:
paths:
.
.
.