Django behind Heroku's reverse proxy causes
request.is_secure()
to always returnFalse
.
- Add
secure_scheme_headers = {'X-FORWARDED-PROTO': 'https'}
to Gunicorn's config. See Sample config- Add
SECURE_PROXY_SSL_HEADER=('HTTP_X_FORWARDED_PROTO', 'https')
in Django settings(development/1.4+). See Django Docs- Add
heroku.middleware.SecureReverseProxyMiddleware
toMIDDLEWARE_CLASSES
- Apply one of the solutions from Heroku Reverse Proxy
- Add
heroku.middleware.HttpsRedirectMiddleware
toMIDDLEWARE_CLASSES