X-FRAME-OPTIONS在哪里:DENY来自Django网站上的nginx? [英] Where is X-FRAME-OPTIONS: DENY coming from on Django site via nginx?

查看:1258
本文介绍了X-FRAME-OPTIONS在哪里:DENY来自Django网站上的nginx?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Django网站在iframe中使用 django-summernote ,并抛出此错误:

My Django site uses django-summernote in iframes, and is throwing this error:


多个'X-Frame-Options'标题,在加载$ b $时遇到冲突值
('SAMEORIGIN,DENY') b' http://example.com/summernote/editor/id_comment_text/ 。回落
到'DENY'。

Multiple 'X-Frame-Options' headers with conflicting values ('SAMEORIGIN, DENY') encountered when loading 'http://example.com/summernote/editor/id_comment_text/'. Falling back to 'DENY'.

我无法弄清楚DENY的来源。

在我的Django项目设置中,我有:

In my Django project settings I have:

MIDDLEWARE_CLASSES = (
    ...
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    ...
)

默认情况下,中间件会为每个传出的HttpResponse 将X-Frame-Options标头设置为SAMEORIGIN。

which: "By default, the middleware will set the X-Frame-Options header to SAMEORIGIN for every outgoing HttpResponse."

我也在我的nginx.conf中添加了这个(来自这里):

I also added this in my nginx.conf (from here):

add_header X-Frame-Options SAMEORIGIN;

其他可能相关的信息:当我将服务器从Ubuntu 14.04升级到16.04时出现问题项目的虚拟环境从Python 3.4到Python 3.5。 Django和django-summernote的版本仍然相同。

Other possibly relevant info: The problem arose when I upgraded my server from Ubuntu 14.04 to 16.04, and by project's virtual environment from Python 3.4 to Python 3.5. The version of Django and django-summernote are still the same.

如何找到此DENY设置的来源?

How do I find the source of this DENY setting?

推荐答案

在我的情况下,问题出现在文件中:
/etc/nginx/snippets/ssl-params.conf

In my case the issue was in the file: /etc/nginx/snippets/ssl-params.conf

只需注释掉:
add_header X-Frame-Options DENY;

Just had to comment out: add_header X-Frame-Options DENY;

这篇关于X-FRAME-OPTIONS在哪里:DENY来自Django网站上的nginx?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆