nginx - 处理Refused to display 'url'... in a frame because it set 'X-Frame-Options' to 'sam...

栏目: 服务器 · Nginx · 发布时间: 6年前

内容简介:参考;今天遇到个问题:某父页面(a.com ) 使用iframe 包含子页面(b.com)时,发现页面是空白页, 显示的是:

nginx - 处理Refused to display 'url'... in a frame because it set 'X-Frame-Options' to 'sameorigin'.

访问量: 5

参考; https://stackoverflow.com/questions/30731290/how-to-set-x-frame-options-allow-from-in-nginx-correctly

https://stackoverflow.com/questions/27358966/how-to-set-x-frame-options-on-iframe

今天遇到个问题:某父页面(a.com ) 使用iframe 包含子页面(b.com)时,发现页面是空白页, 显示的是:

Refused to display 'url'... in a frame because it set 'X-Frame-Options' to 'sameorigin'.

原因是: 子页面的response并没有返回 相关的header.

解决办法:

为子页面的nginx 中,添加:

location ~ ^/(images|javascripts|stylesheets|upload|assets|video)/  {
        root /mnt/www/your-project/public;
        expires 30d;
        add_header Cache-Control public;
        add_header ETag "";
        add_header X-Frame-Options "allow-from http://a.com";  // a.com 是父页面

      }

另外, 对于chrome ,可能还需要多返回一个: (参考: https://stackoverflow.com/questions/30731290/how-to-set-x-frame-options-allow-from-in-nginx-correctly

add_header Content-Security-Policy: frame-ancestors a.com


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

智能商业

智能商业

曾鸣 / 中信出版集团 / 2018-11 / 68.00

《智能商业》由马云作序推荐。《智能商业》是阿里巴巴集团前总参谋长曾鸣,对互联网时代的重要趋势做出革命性解读的作品,披露了其对于未来商业模式的思考和判断。 2006年,曾鸣教授加入阿里巴巴集团,参与阿里巴巴集团及各重要业务线,如淘宝、支付宝、阿里云计算、菜鸟等的发展,被业界称为阿里的“军师”。 基于在阿里巴巴集团十几年的实践经验,以及对互联网、大数据和人工智能的深入思考,曾鸣教授在《智能......一起来看看 《智能商业》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

MD5 加密
MD5 加密

MD5 加密工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具