kubernetes-ingress
kubernetes-ingress copied to clipboard
Add response header in nginx controller only if upstream server has NOT already added header
We have a Nginx Ingress controller in which we add bunch of response headers. For example
http-snippets: |-
add_header X-Frame-Options "SAMEORIGIN" always;
add_header Content-Security-Policy " *.something.com" always;
add_header X-Content-Type-Options "nosniff" always;
We want to set those headers in all our Ingress Resources, so we are using ConfigMap keys for http snippet.
We have a scenario where upstream adds one of these headers. In that case we want Nginx Ingress controller to NOT add the same header else it results in duplicate headers .
Is there a way to tell Nginx Ingress controller to NOT add same header if upstream has already added same header ?
Hi @dhatri308 thanks for reporting!
Be sure to check out the docs while you wait for a human to take a look at this :slightly_smiling_face:
Cheers!
# Override CORS header from upstream server
proxy_hide_header Access-Control-Allow-Origin;
add_header 'Access-Control-Allow-Origin' '*';
This is the only way I think....