Nginx remove header from upstream

http-headersnginx

I have nginx with upstream.

The upstream sets headers:

Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache

Because I want this page to be cached, in nginx I have following conf:

    location ~* ^.+\.(html)$ {
            proxy_pass      http://websitefarm.php73;

            add_header      Pragma          "";
            add_header      x-pragma        "OK";
            expires         1d;
    }

it successfully remove Expires and Cache-Control, but Pragma stays.

note my test header "x-pragma" is set. so definitely conf "works"

expires: Sat, 25 Jul 2020 12:13:04 GMT
cache-control: max-age=86400
pragma: no-cache
x-pragma: OK

if i try set "Pragma" to something else, it works, but "" not seems to work.

Best Answer

Seems like this can be removed only with proxy_hide_header directive

Following config works:

    location ~* ^.+\.(html)$ {
            proxy_pass              http://websitefarm.php73;
            proxy_hide_header       Pragma;
            expires                 1d;
    }