settings.py
USE_X_FORWARDED_HOST = True
SECURE_PROXY_SSL_HEADER = (‘HTTP_X_FORWARDED_PROTO‘, ‘https‘)
nginx.conf
# Finally, send all non-media requests to the Django server.
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header Host $http_host;
proxy_redirect off;
if (!-f $request_filename) {
proxy_pass http://app_django_server;
break;
}
}