Docker: BEHIND_HTTPS and BEHIND_PROXY

Fix #164
This commit is contained in:
Klaas van Schelven
2025-07-25 16:30:34 +02:00
parent b993112558
commit b432d3f6b6
2 changed files with 27 additions and 5 deletions

View File

@@ -1,3 +1,4 @@
import os
import urllib.parse
from django.core.checks import Warning, register
@@ -58,3 +59,20 @@ def check_base_url_is_url(app_configs, **kwargs):
)]
return []
@register("bsmain")
def check_proxy_env_vars_consistency(app_configs, **kwargs):
# in this check we straight-up check the os.environ: we can't rely on settings.BEHIND_HTTPS_PROXY to have been set
# since it's Docker-only.
if (
os.getenv("BEHIND_HTTPS_PROXY", "False").lower() in ("true", "1", "yes") and
os.getenv("BEHIND_PLAIN_HTTP_PROXY", "False").lower() in ("true", "1", "yes")
):
return [Warning(
"BEHIND_HTTPS_PROXY and BEHIND_PLAIN_HTTP_PROXY are mutually exclusive.",
id="bsmain.W004",
)]
return []