覆盖从 nginx 代理的 Web 应用程序服务器返回的 HTTP 标头

cis*_*cis 6 nginx reverse-proxy http-headers

我有一个在 nginx 1.15 后面反向代理的 Web 应用程序服务器,如下所示:

location / {
   proxy_pass https://some.awesome.IP:8080;
   proxy_set_header Host            $host;
   proxy_set_header X-Forwarded-For $remote_addr;
}
add_header Content-Security-Policy "default-src 'self'; frame-ancestor https://subdomain.domain.org 'self'";
Run Code Online (Sandbox Code Playgroud)

现在这个 Web 应用程序服务器认为将标头设置Content-Security-Policyframe-ancestors 'self'- 这会破坏我的前端,因为我需要将该页面包装在托管于 的 iframe 中https://subdomain.domain.org

那么,在将响应传递给客户端之前,如何在 nginx 中更改/覆盖/删除从 Web 应用程序服务器返回的标头?add_header这里显然被忽略了。

cis*_*cis 6

看来添加proxy_hide_header Content-Security-Policy;确实起到了作用。