kubernetes-ingress icon indicating copy to clipboard operation
kubernetes-ingress copied to clipboard

Add response header in nginx controller only if upstream server has NOT already added header

Open dhatri308 opened this issue 3 years ago • 3 comments
trafficstars

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 ?

dhatri308 avatar Mar 24 '22 21:03 dhatri308

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!

github-actions[bot] avatar Mar 24 '22 21:03 github-actions[bot]

# 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....

bumkey1101 avatar Mar 17 '23 06:03 bumkey1101