【问题标题】:X-Frame-Options header is not a recognized directiveX-Frame-Options 标头不是可识别的指令
【发布时间】:2018-05-23 00:07:01
【问题描述】:

我现在使用 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.

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

【问题讨论】:

    标签: nginx http-headers nextcloud


    【解决方案1】:

    allow-from 已“过时”。您可以改用 Content-Security-Policy 标头:

    header('Content-Security-Policy: frame-ancestors https://example.com');
    

    【讨论】:

      【解决方案2】:

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

      但是该选项在 Firefox 上有效(更多信息:https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options)。

      【讨论】:

        猜你喜欢
        • 2017-11-30
        • 2021-04-10
        • 2013-11-16
        • 1970-01-01
        • 2019-03-15
        • 2017-02-09
        • 2021-10-17
        • 2020-07-21
        • 2022-12-18
        相关资源
        最近更新 更多