如何删除X-Frame-Options?

问题描述 投票:0回答:2

我尝试从服务器响应中删除 X-Frame-Options,但它不起作用。 Nginx 版本 1.17.8.

我使用proxy_pass。 我确实尝试过这样的:

proxy_hide_header 'x-frame-options';

还有这个:

add_header X-Frame-Options "";

我也尝试过像这样使用 headers-more-nginx-module :

more_set_headers "x-frame-options";

还有这个:

more_clear_headers "X-Frame-Options";
more_clear_headers "x-frame-options";

当我尝试在 iframe 中渲染页面时,总是出现错误:

Refused to display 'URL_PAGE' in a frame because it set 'X-Frame-Options' to 'sameorigin'.

Curl -I 结果:

HTTP/2 200
accept-ranges: bytes
content-security-policy: frame-src  'self' *;
content-type: text/html
date: Thu, 09 Sep 2021 16:50:50 GMT
strict-transport-security: max-age=15552000; includeSubDomains; preload
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
x-xss-protection: 1; mode=block

有什么想法吗?

nginx nginx-reverse-proxy
2个回答
1
投票

使用特定的URL会更安全,例如:

add_header X-Frame-Options "Allow-From URL";
URL 应该是您需要在其上制作 Iframe 的 URL。

但是,如果您需要完全禁用此标头,请尝试在

/etc/nginx/sites-available/default
处尝试不带引号的第一个代码,如下所示:
proxy_hide_header x-frame-options;

然后重新启动服务器。


0
投票

我是否需要重新编译 nginx 才能删除 x-xss-protection?

© www.soinside.com 2019 - 2024. All rights reserved.