From c8c291e2b874e5864071d29a94df2139e8053d6d Mon Sep 17 00:00:00 2001 From: Michael Herrmann Date: Mon, 12 Jun 2023 15:32:41 +0200 Subject: [PATCH] Serve media files under httpS:// in prod --- conf/nginx/nginx | 2 +- core/settings.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/conf/nginx/nginx b/conf/nginx/nginx index d4f5b2a..8c40af0 100644 --- a/conf/nginx/nginx +++ b/conf/nginx/nginx @@ -39,7 +39,7 @@ server { location / { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Protocol $scheme; + proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Host $host; proxy_redirect off; if (!-f $request_filename) { diff --git a/core/settings.py b/core/settings.py index 22d2741..131ac3c 100644 --- a/core/settings.py +++ b/core/settings.py @@ -140,4 +140,8 @@ REST_FRAMEWORK = { 'DEFAULT_PERMISSION_CLASSES': [ 'rest_framework.permissions.IsAuthenticated' ] -} \ No newline at end of file +} + +# Make sure Django returns https:// URLs when invoked over https. +USE_X_FORWARDED_HOST = True +SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') \ No newline at end of file