django 使用 heroku 设置变量 SECURE_PROXY_SSL_HEADER

标签 django http ssl heroku django-settings

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

在django 1.8教程中它说

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):

  • Your Django app is behind a proxy.
  • Your proxy strips the X-Forwarded-Proto header from all incoming requests. In other words, if end users include that header in their requests, the proxy will discard it.
  • Your proxy sets the X-Forwarded-Proto header and sends it to Django, but only for requests that originally come in via 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 时,是否满足所有这些条件?我应该继续吗?

最佳答案

是的 - 你应该没问题 - 请参阅 heroku 文档:https://devcenter.heroku.com/articles/http-routing#heroku-headers

关于django 使用 heroku 设置变量 SECURE_PROXY_SSL_HEADER,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37539409/

相关文章:

c++ - 处理 SSL 客户端不读取所有数据

html - 使用 Delphi 2009 下载任何网页并将其保存为 Unicode?

google-chrome - Google Chrome 拒绝访问证书错误的网站

Django 转移到 PostgreSQL 无法导入固定装置,说明数据太长

python - 单个 Django 项目的两个虚拟环境?

Django get request.POST.get() 参数未按预期工作,参数名称带括号[]

mysql - 将 Mysql group by 转换为 ORM

facebook - 将视频字幕文件上传到 Facebook?

javascript - 浏览器中的 websocket 客户端可以发送 header 吗?

google-app-engine - GAE SSL 证书要求