[Django]-Django MEDIA_URL returns http instead of https

15👍

First, make sure Nginx is sending the X-Forwarded-Proto header, it should be set to:

proxy_set_header X-Forwarded-Proto https;

Then in your Django settings add the following:

USE_X_FORWARDED_HOST = True
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

In this way you will instruct Django to use the proto passed by the proxy.

👤bug

Leave a comment