From 35331a4295d1740c71e77debfec6c3081bc767c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chris=20Sch=C3=A4pers?= Date: Sun, 20 Mar 2022 13:27:39 +0100 Subject: [PATCH] Make gunicorn IPv6 conditional Only listen on [::]:80 in case SUBNET6 is defined, otherwise do the normal :80 --- core/admin/start.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/admin/start.py b/core/admin/start.py index c5b3bc23..debb4ec7 100755 --- a/core/admin/start.py +++ b/core/admin/start.py @@ -52,10 +52,15 @@ def test_DNS(): test_DNS() +bind_addr = ":80" +if os.environ.get("SUBNET6") is not None: + # If SUBNET6 is defined, gunicorn must listen on IPv6 as well as IPv4 + bind_addr = "[::]:80" + start_command=" ".join([ "gunicorn", f"--threads {str(os.cpu_count())}", - "-b [::]:80", + "-b", bind_addr, "--logger-class mailu.Logger", "--worker-tmp-dir /dev/shm", "--access-logfile -" if (log.root.level<=log.INFO) else "",