From cb53e2e548ed360b8a8fcba71b06824f22826f4a Mon Sep 17 00:00:00 2001 From: ajnart Date: Sat, 8 Aug 2026 00:59:44 +0200 Subject: [PATCH] fix: keep nginx IPv6 listen only when IPv6 is available (#4596) Commit 2c48b1896 (1.45.2) made the internal nginx proxy listen on the IPv6 wildcard ('listen [::]:7575;'), which aborts nginx startup on hosts/VMs with IPv6 disabled: nginx: [emerg] socket() [::]:7575 failed (97: Address family not supported by protocol) A plain revert would reintroduce #2697 and break IPv6-only/dual-stack environments where this listener is required. Instead, only emit the IPv6 listen directive when the host actually has IPv6 configured. Reuse the envsubst step run.sh already performs: compute NGINX_LISTEN_IPV6 from /proc/net/if_inet6 and substitute it into the template. proc files always report size 0, so presence is detected by grepping the file (not 'test -s'). --- nginx.conf | 2 +- scripts/run.sh | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/nginx.conf b/nginx.conf index c1c082777..7754b4087 100644 --- a/nginx.conf +++ b/nginx.conf @@ -5,7 +5,7 @@ events { http { server { listen 7575; - listen [::]:7575; + ${NGINX_LISTEN_IPV6} # Route websockets traffic to port 3001 location /websockets { diff --git a/scripts/run.sh b/scripts/run.sh index 83eff588e..6afa56e94 100644 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -24,8 +24,13 @@ export AUTH_SECRET=$(openssl rand -base64 32) # 1. Replace the HOSTNAME in the nginx template file # 2. Create the nginx configuration file from the template # 3. Start the nginx server +# Only listen on IPv6 when the host actually has IPv6 configured (#4596). +# Otherwise nginx aborts with "socket() [::]:7575 failed (97: Address family +# not supported by protocol)". Note: (test -s) cannot be used here as proc files +# always report size 0, so IPv6 presence is detected via grep on the file. export HOSTNAME -envsubst '${HOSTNAME}' < /etc/nginx/templates/nginx.conf > /etc/nginx/nginx.conf +export NGINX_LISTEN_IPV6="$(grep -q . /proc/net/if_inet6 2>/dev/null && echo 'listen [::]:7575;')" +envsubst '${HOSTNAME} ${NGINX_LISTEN_IPV6}' < /etc/nginx/templates/nginx.conf > /etc/nginx/nginx.conf # Start services in the background and store their PIDs nginx -g 'daemon off;' & NGINX_PID=$!