15

我现在使用 Nextcloud(在 Nginx 上)有一段时间了,我想将它 iframe 用于另一个网站。但是标题不接受我的指令。

我将 /var/www/nextcloud/lib/private/legacy/response.php 中的标头选项更改为以下内容:

header('X-Frame-Options: ALLOW-FROM https://example.com');

但是,当我使用 iframe 制作示例网页时,会出现以下错误:

Invalid 'X-Frame-Options' header encountered when loading 'https://nextcloud.example.com/apps/files/': 'ALLOW-FROM https://example.com' is not a recognized directive. The header will be ignored.

有谁知道为什么这不起作用?

4

2 回答 2

19

allow-from是“过时的”。您可以改用Content-Security-Policy标题:

header('Content-Security-Policy: frame-ancestors https://example.com');
于 2019-11-29T12:41:52.060 回答
14

回到这篇文章。不幸的是,我发现了问题。Chrome 不支持此选项,因此 Chrome 给了我 iframe 将我重定向到多次的错误。

但是该选项适用于 Firefox(更多信息在这里:https ://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options )。

于 2017-12-19T12:36:53.733 回答