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').
This commit is contained in:
ajnart committed 2026-08-08 00:59:44 +02:00
1 parent 06724cfeb2
commit cb53e2e548
2 files changed
+7 -2

No files matched your search

+1 -1
View File
@@ -5,7 +5,7 @@ events {
http {
server {
listen 7575;
listen [::]:7575;
${NGINX_LISTEN_IPV6}
# Route websockets traffic to port 3001
location /websockets {
+6 -1
View File
@@ -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=$!