Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force redirect http to https using SECURE_SSL_REDIRECT = True #77

Open
BuildWithLal opened this issue Jul 8, 2018 · 2 comments
Open

Comments

@BuildWithLal
Copy link

BuildWithLal commented Jul 8, 2018

From Django docs on SECURE_SSL_REDIRECT

If True, the SecurityMiddleware redirects all non-HTTPS requests to HTTPS 

i have added django.middleware.security.SecurityMiddleware to MIDDLEWARE list in settings.py

Using SECURE_SSL_REDIRECT = True with runsslserver doesn't redirect all http traffic to https, even the server is not gonna hit from browser/client when try with http

This issue is asked and well described here on stackoverflow

https://stackoverflow.com/questions/41221890/redirect-http-to-https-in-django-using-sslserver

Django==2.0
Python==3.6
django-sslserver==0.20
@LemonLzy
Copy link

How is it going now

I also encountered the same problem

@jessysu
Copy link

jessysu commented Apr 8, 2022

Worked for me.

In addition to SECURE_SSL_REDIRECT=True in settings.py as mentioned, you need both

  1. runsslserver on port 443
  2. runserver on port 80

To have a service listening on 80 and do the redirect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants