I have an application that uses \"secure\" cookies and want to test it\'s functionality without needing to set up a complicated SSL enabled development server. Is there any
Handle SSL/TLS with a proxy such as Nginx rather than Django. Nginx can be set up to listen on port 443 and then forward requests to your Django dev server (typically http://127.0.0.1:8000
). An Nginx configuration for this might look like the following:
server {
listen 443 ssl;
server_name django-dev.localhost;
ssl_certificate /etc/ssl/certs/nginx_chain.pem;
ssl_certificate_key /etc/ssl/private/nginx.pem;
location / {
proxy_pass http://127.0.0.1:8000/;
proxy_set_header Host $host;
}
}
You'll also need to map django-dev.localhost
to 127.0.0.1
and add django-dev.localhost
to ALLOWED_HOSTS
in settings.py
. On Linux, you'll need to add the following line to /etc/hosts
:
127.0.0.1 django-dev.localhost
You'll then be able to reach your dev site by going to https://django-dev.localhost
in your browser (you will need to bypass your browser's security warning).