【问题标题】:How to fix Safari ignoring Content-Security-Policy when X-Frame-Options are specified on Apache?当在 Apache 上指定 X-Frame-Options 时,如何修复 Safari 忽略 Content-Security-Policy?
【发布时间】:2019-06-25 02:13:29
【问题描述】:

this question相关

我在另一个域中的 iframe 无法在 Safari 上正确加载并且不知道该怎么做。问题是截至 2019 年 1 月的 Safari 12 仍然优先考虑 X-Frame-Options 而不是 Content-Security-Policy

我在 .htaccess 中有以下配置:

Header always append X-Frame-Options SAMEORIGIN
Header always append Content-Security-Policy "frame-ancestors 'self' *.master-domain.com *.alternative-domain.com"

虽然这在 Firefox、Chrome 甚至 Edge 中都能完美运行(当发送功能更丰富的 Content-Security-Policy 时,都只是忽略现在已弃用的 X-Frame-Options),但出于某种原因,Safari 会选择优先考虑旧的 X-Frame-Options .此外,Safari 本身会考虑默认 X-Frame-Options: DENY ,而不像其他浏览器一样允许所有。这使得在 Safari 中跨多个域加载 iframe 几乎是不可能的。

【问题讨论】:

    标签: apache safari


    【解决方案1】:

    最好的解决方法是仅使用 BrowserMatch 和条件标头语法为 Safari 删除标头

    BrowserMatch "Safari" ISSAFARIBROWSER
    Header always append X-Frame-Options SAMEORIGIN
    Header always unset X-Frame-Options env=ISSAFARIBROWSER
    Header always append Content-Security-Policy "frame-ancestors 'self' *.master-domain.com *.alternative-domain.com"
    

    【讨论】:

      猜你喜欢
      • 2017-03-15
      • 2015-09-09
      • 1970-01-01
      • 2016-09-14
      • 2013-06-10
      • 1970-01-01
      • 2023-03-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多