From 8e3660d9e195ded60146dfd4a5a6988caca29f9a Mon Sep 17 00:00:00 2001 From: Rechner Fox <659028+rechner@users.noreply.github.com> Date: Tue, 13 Feb 2024 16:36:57 -0800 Subject: [PATCH 1/3] Fix debug flag cast --- fm_eventmanager/settings.py.docker | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fm_eventmanager/settings.py.docker b/fm_eventmanager/settings.py.docker index 7e685791..9858e835 100644 --- a/fm_eventmanager/settings.py.docker +++ b/fm_eventmanager/settings.py.docker @@ -58,7 +58,7 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) SECRET_KEY = os.environ['DJANGO_SECRET_KEY'] # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = os.getenv('DJANGO_DEBUG', False) +DEBUG = eval_bool(os.getenv('DJANGO_DEBUG', False)) LOGGING = { 'version': 1, From 2d42c0ffedee249ad471b4f4d4b0597dc647826f Mon Sep 17 00:00:00 2001 From: Rechner Fox <659028+rechner@users.noreply.github.com> Date: Tue, 13 Feb 2024 16:49:21 -0800 Subject: [PATCH 2/3] Set internal IPs to work with docker --- fm_eventmanager/settings.py.docker | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fm_eventmanager/settings.py.docker b/fm_eventmanager/settings.py.docker index 9858e835..99f3e895 100644 --- a/fm_eventmanager/settings.py.docker +++ b/fm_eventmanager/settings.py.docker @@ -321,7 +321,10 @@ MAINTENANCE_MODE_IGNORE_URLS = ("^/u2f/",) LOGIN_REDIRECT_URL = 'u2f:two-factor-settings' LOGIN_URL = 'u2f:login' -INTERNAL_IPS = ['127.0.0.1'] +if DEBUG: + import socket # only if you haven't already imported this + hostname, _, ips = socket.gethostbyname_ex(socket.gethostname()) + INTERNAL_IPS = [ip[: ip.rfind(".")] + ".1" for ip in ips] + ["127.0.0.1", "10.0.0.4"] # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.9/howto/static-files/ From 24363135be41f681b2251f7fbf044c7318124b8e Mon Sep 17 00:00:00 2001 From: Rechner Fox <659028+rechner@users.noreply.github.com> Date: Wed, 14 Feb 2024 16:53:30 -0800 Subject: [PATCH 3/3] Add optional internal proxy host to internal_ips --- fm_eventmanager/settings.py.docker | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fm_eventmanager/settings.py.docker b/fm_eventmanager/settings.py.docker index 99f3e895..139a13bc 100644 --- a/fm_eventmanager/settings.py.docker +++ b/fm_eventmanager/settings.py.docker @@ -322,9 +322,13 @@ LOGIN_REDIRECT_URL = 'u2f:two-factor-settings' LOGIN_URL = 'u2f:login' if DEBUG: + # Adds docker NAT routers and any internal upstream proxies as internal IPs to enable the debug toolbar import socket # only if you haven't already imported this - hostname, _, ips = socket.gethostbyname_ex(socket.gethostname()) - INTERNAL_IPS = [ip[: ip.rfind(".")] + ".1" for ip in ips] + ["127.0.0.1", "10.0.0.4"] + INTERNAL_IPS = ["127.0.0.1"] + for proxy_host in (socket.gethostname(), os.getenv("INTERNAL_PROXY_HOST")): + if proxy_host: + hostname, _, ips = socket.gethostbyname_ex(proxy_host) + INTERNAL_IPS += [ip[: ip.rfind(".")] + ".1" for ip in ips] + ips # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.9/howto/static-files/