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=$!