7👍
✅
server {
listen 80;
server_name yourhttphost;
rewrite ^ https://yourhttpshost$request_uri? permanent; #301 redirect
}
server {
listen 443;
server_name yourhttpshost;
........
the rest
........
}
Using “if” in nginx config is a very bad idea!
14👍
I needed a bit more to make Django aware that it should be using https.
In settings.py I added
SECURE_PROXY_SSL_HEADER = (‘HTTP_X_FORWARDED_PROTO’, ‘https’)
And in the nginx configuration
location / {
proxy_set_header X-Forwarded-Proto https;
include uwsgi_params;
uwsgi_param UWSGI_SCHEME https;
uwsgi_pass_header X_FORWARDED_PROTO;
uwsgi_pass unix:///path/to/socket;
}
- How do I update an object's members using a dict?
- Systemctl strange error: Invalid arguments
- Is it possible to stop Django from creating .pyc files, whilst in development?
- Limit Maximum Choices of ManyToManyField
- Django datefield and timefield to python datetime
- Django: use render_to_response and set cookie
- Django query how to write: WHERE field LIKE '10__8__0__'?
- Django: datetime filter by date ignoring time
Source:stackexchange.com