django用heroku设置变量SECURE_PROXY_SSL_HEADER [英] django setting variable SECURE_PROXY_SSL_HEADER with heroku

查看:188
本文介绍了django用heroku设置变量SECURE_PROXY_SSL_HEADER的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用heroku在django 1.8上设置与https / ssl相关的变量。但是在Django 1.8教程中,它说我应该特别小心地设置此变量 SECURE_PROXY_SSL_HEADER =('HTTP_X_FORWARDED_PROTO','https')

I am trying to set variables related to https/ssl on django 1.8 with heroku. but in Django 1.8 tutorial, it saids that i should be careful setting this variable expecially "SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')"

在Django 1.8教程中说

In django 1.8 tutorial it saids


警告

Warning

如果您可能会在站点中打开安全漏洞设置此
而不知道您在做什么。而且如果您在
应该设置的时间内未设置它。认真。

You will probably open security holes in your site if you set this without knowing what you’re doing. And if you fail to set it when you should. Seriously.

在设置此项之前,请确保以下所有内容均正确(假设
是上面示例中的值):

Make sure ALL of the following are true before setting this (assuming the values from the example above):


  • 您的Django应用位于代理之后。

  • 您的代理会从所有传入请求中删除X-Forwarded-Proto标头。换句话说,如果最终用户在
    请求中包含该标头,则代理会将其丢弃。

  • 您的代理会设置X-Forwarded-Proto标头并将其发送给Django ,但仅适用于最初通过HTTPS发出的请求。

如果其中任何一个都不正确,则应将此设置保持为没有
并找到另一种确定HTTPS的方法,也许可以通过自定义
中间件来实现。

If any of those are not true, you should keep this setting set to None and find another way of determining HTTPS, perhaps via custom middleware.

当我使用heroku时是否满足所有这些条件?我应该继续吗?

And when i use heroku does if fulfill all these conditions? Should i keep going on?

推荐答案

是的-您应该还可以-请参见heroku文档: https://devcenter.heroku.com/articles/http-routing#heroku-headers

yep - you should be fine - see the heroku docs: https://devcenter.heroku.com/articles/http-routing#heroku-headers

这篇关于django用heroku设置变量SECURE_PROXY_SSL_HEADER的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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