From c483b5608cfd891b2146dd997e86db1f3a4271b2 Mon Sep 17 00:00:00 2001 From: ajnart Date: Sat, 8 Aug 2026 09:01:38 +0200 Subject: [PATCH] fix: honor HOMARR_DISABLE_IPV6 override in nginx config generation Review feedback on #6539: give users an explicit opt-out from the IPv6 listener even when the host reports IPv6. The issue reporter (#4596) requested such an env var, and the pattern matches the existing ENABLE_DNS_CACHING IPv6 toggle. Auto-detection behavior is unchanged when the var is unset. Validated in containers: override wins, dual-stack preserved by default, IPv4-only fallback on IPv6-less hosts. --- .../docs/advanced/environment-variables/index.mdx | 15 ++++++++------- scripts/run.sh | 10 +++++++--- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/apps/docs/docs/advanced/environment-variables/index.mdx b/apps/docs/docs/advanced/environment-variables/index.mdx index e7dc6960d..f2ae41d4b 100644 --- a/apps/docs/docs/advanced/environment-variables/index.mdx +++ b/apps/docs/docs/advanced/environment-variables/index.mdx @@ -25,13 +25,14 @@ This is especially useful for [docker secrets](https://docs.docker.com/engine/sw Using the `PUID` and `PGID` will require you to set the correct permissions on the mounted volumes and if used the docker socket. See more in the [Running as a different user](/docs/advanced/running-as-different-user) documentation. ::: -| Environment Variable | Description | Possible values | Default | -| ------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------- | ------- | -| `PUID` | User ID to run the container as | Any valid user ID | `0` | -| `PGID` | Group ID to run the container as | Any valid group ID | `0` | -| `LOG_LEVEL` | Log level to use | `debug` / `info` / `warn` / `error` | `info` | -| `NO_EXTERNAL_CONNECTION` | Disables Homarr's internet-backed requests, including update checks, weather, and RSS feeds | `true` or `false` | `false` | -| `ENABLE_DNS_CACHING` | Enables dns caching. Enabled by default, but if you experience issues with IPv6 or static IPs, see [#4006](https://github.com/homarr-labs/homarr/issues/4006) or disable this flag | `true` or `false` | `true` | +| Environment Variable | Description | Possible values | Default | +| ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------- | ------- | +| `PUID` | User ID to run the container as | Any valid user ID | `0` | +| `PGID` | Group ID to run the container as | Any valid group ID | `0` | +| `LOG_LEVEL` | Log level to use | `debug` / `info` / `warn` / `error` | `info` | +| `NO_EXTERNAL_CONNECTION` | Disables Homarr's internet-backed requests, including update checks, weather, and RSS feeds | `true` or `false` | `false` | +| `ENABLE_DNS_CACHING` | Enables dns caching. Enabled by default, but if you experience issues with IPv6 or static IPs, see [#4006](https://github.com/homarr-labs/homarr/issues/4006) or disable this flag | `true` or `false` | `true` | +| `HOMARR_DISABLE_IPV6` | Disables the IPv6 listener of the internal nginx proxy, even when the host supports IPv6. IPv6 is normally disabled automatically when the host has no IPv6 configured. See [#4596](https://github.com/homarr-labs/homarr/issues/4596) | `true` or `false` | `false` | ## Authentication diff --git a/scripts/run.sh b/scripts/run.sh index 6afa56e94..6357c723c 100644 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -26,10 +26,14 @@ export AUTH_SECRET=$(openssl rand -base64 32) # 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. +# not supported by protocol)". Check HOMARR_DISABLE_IPV6 first so users can +# force IPv4-only even when the host supports IPv6, then probe for IPv6 +# addresses via grep (not -s: proc files always report size 0). export HOSTNAME -export NGINX_LISTEN_IPV6="$(grep -q . /proc/net/if_inet6 2>/dev/null && echo 'listen [::]:7575;')" +export NGINX_LISTEN_IPV6='' +if [ "${HOMARR_DISABLE_IPV6:-false}" != "true" ] && grep -q . /proc/net/if_inet6 2>/dev/null; then + NGINX_LISTEN_IPV6='listen [::]:7575;' +fi 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;' &