WeGi
WeGi

Reputation: 1946

Secure_ssl_redirect setting for django does nothing on heroku

I am deploying a Django app on heroku and trying to force https on all pages. I use the following settings for that:

SECURE_SSL_REDIRECT = True
SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

Now when I visit www.mysite.de it does in fact not redirect me to https. Any ideas what I am missing?

Upvotes: 6

Views: 9522

Answers (1)

YPCrumble
YPCrumble

Reputation: 28722

Try adding the following to your settings.py:

PREPEND_WWW = True
BASE_URL = "https://www.mysite.de"
ALLOWED_HOSTS = ['www.mysite.de', 'mysite.de']

Make sure you also have SecurityMiddleware and CommonMiddleware enabled.

Upvotes: 11

Related Questions