拒绝在iframe中显示网站,X-Frame-Options to' SAMEORIGIN'

时间:2014-06-26 01:53:23

标签: iframe x-frame-options

尝试检查chrome中的元素时出错:

拒绝展示' http://www.samplesite.com/'在一个框架中,因为它设置了X-Frame-Options'到' SAMEORIGIN'。

如何在网站所拥有的iframe中显示网站 ' X型框架,选项'到#SAMEORIGIN'?

我尝试在谷歌搜索,但我找不到一些解决方案,有些仅适用于asp.net。

4 个答案:

答案 0 :(得分:3)

Web服务器conf,

对我来说,我使用的是nginx.conf

找到add_header X-Frame-Options SAMEORIGIN;并将其更改为add_header X-Frame-Options "ALLOWALL";

您的网络服务器发送标头并阻止内容。您应该将此设置更改为允许来自同一来源。

答案 1 :(得分:0)

要解决此错误:

Issue as mentioned in screenshot

您只需根据要提供的访问级别将此代码放入.htaccess文件中即可。

  1. X-Frame-Options: deny
  2. X-Frame-Options: sameorigin
  3. X-Frame-Options: "allow-from https://example.com/"

答案 2 :(得分:0)

我也有类似的问题。将网页加载到另一个网站上的iframe中时,出现此错误: 拒绝在框架中显示“ https://mywebsite.com”,因为它将“ X-Frame-Options”设置为“ sameorigin”。

我已经解决了使用此网络组件的问题,该组件允许IFrame绕过X-Frame-Options:deny / sameorigin响应标头。 https://github.com/niutech/x-frame-bypass

要进行测试,只需将此代码保存在 index.html 文件中,然后将文件 x-frame-bypass.js 放在同一目录中即可下载从上面的Github存储库中获取。

由于Safari不支持自定义内置元素,因此我添加了一个额外的脚本来支持该功能。 https://www.chromestatus.com/feature/4670146924773376

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>X-Frame-Bypass For Global CI calendar</title>
    <style>
        html, body {
            margin: 0;
            padding: 0;
            height: 100%;
            overflow: hidden;
        }
        iframe {
            display: block;
            width: calc(100% - 40px);
            height: calc(100% - 40px);
            margin: 20px;
            border: 0;
        }

    </style>

    <!-- To bypass the CROSS ORIGIN Resource issue -->
        <script src="x-frame-bypass.js" type="module"></script>

    <!-- Support Customized built-in elements for Safari-->
        <script src="https://unpkg.com/@ungap/custom-elements-builtin"></script>

</head>
<body>
    <iframe is="x-frame-bypass" src="https://www.link_to_any_website.com"></iframe>
</body>
</html>

答案 3 :(得分:0)

某些网站阻止您这样做。您可以做的是使用第三方工具,该工具可以通过使用代理https://cors.io

来解决它

尽管这是一个冒险的解决方案