pip install django-sslserver
settings.py
INSTALLED_APPS = [
...
'sslserver'
]
...
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
SECURE_SSL_REDIRECT = False
SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True
...
: point_up: Create an SSL certificate
python
openssl genrsa -out foobar.key 2048
openssl req -new -key foobar.key -out foobar.csr
openssl x509 -req -days 365 -in foobar.csr -signkey foobar.key -out foobar.crt
Start the server again
python manage.py runsslserver 0.0.0.0:8000 --certificate /path/to/foobar.crt --key /path/to/foobar.key
That's it: hugging:
Even so, it's a metaphysical https, so let's have the certificate issued in a proper place.
Recommended Posts