【问题标题】:Apache X-Frame-Options conflict for IE and Chrome (only either one worked!)IE 和 Chrome 的 Apache X-Frame-Options 冲突(只有一个有效!)
【发布时间】:2018-08-01 22:48:00
【问题描述】:

我有一个网站,我需要从它本身以及另一个 URL 加载资源。

因此,在 Apache 中,我同时添加了 SAMEORIGIN 和 ALLOW-FROM。

有趣的是,Chrome 拒绝显示该页面,指出存在多个值冲突的 X-Frame-Options 标头,然后退回到“拒绝”。另一方面,IE 运行良好!

我通过删除 SAMEORIGIN 对其进行了修改,并将我的原始站点 URL 添加到 ALLOW-FROM 中。这一次,Chrome 可以,但 IE 不行!

如果您想尝试,以下是我使用的遇到问题的设置:

# Test 1: Use these 2 lines will make IE work, but not Chrome
Header always append X-Frame-Options "SAMEORIGIN"
Header always append X-Frame-Options "ALLOW-FROM https://www.google.com"

# Test 2: Use these 2 lines will make Chrome work, but not IE 
# (<MyBaseServerURL> represents the location as indicated by the "SAMEORIGIN")
Header always append X-Frame-Options "ALLOW-FROM https://www.google.com"
Header always append X-Frame-Options "ALLOW-FROM https://<MyBaseServerURL>"

有人可以建议我如何解决这个问题吗?

感谢和问候, 杰基

【问题讨论】:

  • 由于缺乏答案,我在思考是否没有其他人有这个问题?或者这是无法解决的问题?我没有说清楚吗?还是……?

标签: apache google-chrome internet-explorer x-frame-options same-origin-policy


【解决方案1】:

这是因为 ALLOW-FROM 仅在 FireFox 中受支持。

改用内容安全策略。

Nginx:

add_header Content-Security-Policy "frame-src self *.mydomain.example";

【讨论】:

    【解决方案2】:

    X-Frame-Options HTTP 响应标头可用于指示是否应允许浏览器以 、 或 呈现页面。网站可以使用它来避免点击劫持攻击,确保其内容不会嵌入到其他网站中。

    https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options

    【讨论】:

      猜你喜欢
      • 2014-04-06
      • 2013-06-10
      • 2016-12-09
      • 2021-12-10
      • 1970-01-01
      • 2016-07-12
      • 2013-02-15
      • 2018-02-06
      • 1970-01-01
      相关资源
      最近更新 更多