diff --git a/.env.dev b/.env.dev index e117dbe56..7037b1dbd 100644 --- a/.env.dev +++ b/.env.dev @@ -11,3 +11,4 @@ WEBPACK_DEVSERVER_PORT=8080 MUSIC_DIRECTORY_PATH=/music BROWSABLE_API_ENABLED=True CACHEOPS_ENABLED=False +FORWARDED_PROTO=http diff --git a/api/config/settings/common.py b/api/config/settings/common.py index 50c62e9d5..6ab2a8303 100644 --- a/api/config/settings/common.py +++ b/api/config/settings/common.py @@ -303,6 +303,9 @@ ROOT_URLCONF = 'config.urls' WSGI_APPLICATION = 'config.wsgi.application' ASGI_APPLICATION = "config.routing.application" +# This ensures that Django will be able to detect a secure connection +SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') + # AUTHENTICATION CONFIGURATION # ------------------------------------------------------------------------------ AUTHENTICATION_BACKENDS = ( diff --git a/api/config/settings/production.py b/api/config/settings/production.py index 2866e9103..39be40dc3 100644 --- a/api/config/settings/production.py +++ b/api/config/settings/production.py @@ -22,10 +22,6 @@ from .common import * # noqa # Raises ImproperlyConfigured exception if DJANGO_SECRET_KEY not in os.environ SECRET_KEY = env("DJANGO_SECRET_KEY") -# This ensures that Django will be able to detect a secure connection -# properly on Heroku. -SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') - # django-secure # ------------------------------------------------------------------------------ # INSTALLED_APPS += ("djangosecure", ) diff --git a/docker/nginx/entrypoint.sh b/docker/nginx/entrypoint.sh index 14e072a7e..ea6a3322d 100755 --- a/docker/nginx/entrypoint.sh +++ b/docker/nginx/entrypoint.sh @@ -12,6 +12,7 @@ cp /etc/nginx/funkwhale_proxy.conf{.template,} sed -i "s/X-Forwarded-Host \$host:\$server_port/X-Forwarded-Host ${FUNKWHALE_HOSTNAME}:${FORWARDED_PORT}/" /etc/nginx/funkwhale_proxy.conf sed -i "s/proxy_set_header Host \$host/proxy_set_header Host ${FUNKWHALE_HOSTNAME}/" /etc/nginx/funkwhale_proxy.conf sed -i "s/proxy_set_header X-Forwarded-Port \$server_port/proxy_set_header X-Forwarded-Port ${FORWARDED_PORT}/" /etc/nginx/funkwhale_proxy.conf +sed -i "s/proxy_set_header X-Forwarded-Proto \$scheme/proxy_set_header X-Forwarded-Proto ${FORWARDED_PROTO}/" /etc/nginx/funkwhale_proxy.conf cat /etc/nginx/funkwhale_proxy.conf nginx -g "daemon off;"