14👍
✅
Add these in your Django settings.py
# Setup support for proxy headers
USE_X_FORWARDED_HOST = True
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
6👍
If you are using nginx make sure proper header is set (X-Forwarded-Proto). Actually, check all nginx reverse proxy configs sitting between end-user and web server (gunicorn / uwsgi) like nginx on host machine and e.g. nginx deployed in docker.
location / {
proxy_pass http://django:5000;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# check line below!
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-Referrer $http_referer;
proxy_set_header Referer $http_referer;
}
- How to run multiple Django sites on Nginx and uWSGI?
- Why does JSON returned from the django rest framework have forward slashes in the response?
Source:stackexchange.com