3

How to make django site https in windows10. I am using public IP not local host.

I tried putting the following code in settings.py got from Error "You're accessing the development server over HTTPS, but it only supports HTTP"

CORS_REPLACE_HTTPS_REFERER      = False
HOST_SCHEME                     = "http://"
SECURE_PROXY_SSL_HEADER         = None
SECURE_SSL_REDIRECT             = False
SESSION_COOKIE_SECURE           = False
CSRF_COOKIE_SECURE              = False
SECURE_HSTS_SECONDS             = None
SECURE_HSTS_INCLUDE_SUBDOMAINS  = False
SECURE_FRAME_DENY               = False

I get the following error

[09/Sep/2019 12:50:18] code 400, message Bad request version ('Gð\x1a\x15Ä«Öõß/\x02h|.\x9a\x11,\x93') [09/Sep/2019 12:50:18] You're accessing the development server over HTTPS, but it only supports HTTP.

I even made DEBUG = False

But no use still the same error.

Now my issue is I am lost in trying to implement SSL in django on Windows 10 OS

3 Answers3

2

Django development server (run by python manage.py runserver) cannot handle https.

Check this answer on suggestions.

One of simplest solutions from the answer is to use django-sslserver package.

Other solutions include running some kind of https proxy locally.

Or, run it not in development mode (no live reload) using wsgi server and configuring proper https on it.

Oleg Russkin
  • 4,234
  • 1
  • 8
  • 20
1

you can use ngrok to proxy your local development server to a public https url.

  • Run dev server by running python manage.py runserver
  • Run ngork by running ngrok http 8000. You will get a public https url that you can use to access your local server.
Scott Stafford
  • 43,764
  • 28
  • 129
  • 177
dishant makwana
  • 1,029
  • 6
  • 13
0

You will need to run Django application with uWSGI and Nginx in order to make it work.

The following link will be very helpful, I have tried it on Linux and works smoothly. https://uwsgi-docs.readthedocs.io/en/latest/tutorials/Django_and_nginx.html

Hope this helps :)

Akash Ranjan
  • 922
  • 12
  • 24