django setting variable SECURE_PROXY_SSL_HEADER with heroku

泪湿孤枕 提交于 2019-12-07 02:01:52

问题


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')"

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

  • 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.

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


回答1:


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



来源:https://stackoverflow.com/questions/37539409/django-setting-variable-secure-proxy-ssl-header-with-heroku

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!