From dcd5c3fd6a25c2adea91bd17be5efe61de2c07d5 Mon Sep 17 00:00:00 2001 From: RoboMagus <68224306+RoboMagus@users.noreply.github.com> Date: Fri, 3 Feb 2023 15:55:36 +0100 Subject: [PATCH] Disable listening on IPv6 ports when IPv6 is not supported (#102) --- Dockerfile | 1 + docker/ipv6-disable.sh | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 docker/ipv6-disable.sh diff --git a/Dockerfile b/Dockerfile index 91a40c880..cfbb63300 100644 --- a/Dockerfile +++ b/Dockerfile @@ -56,6 +56,7 @@ ENV VIKUNJA_SENTRY_ENABLED false ENV VIKUNJA_SENTRY_DSN https://85694a2d757547cbbc90cd4b55c5a18d@o1047380.ingest.sentry.io/6024480 COPY docker/injector.sh /docker-entrypoint.d/50-injector.sh +COPY docker/ipv6-disable.sh /docker-entrypoint.d/60-ipv6-disable.sh COPY docker/nginx.conf /etc/nginx/nginx.conf COPY docker/templates/. /etc/nginx/templates/ # copy compiled files from stage 1 diff --git a/docker/ipv6-disable.sh b/docker/ipv6-disable.sh new file mode 100644 index 000000000..4a9172b54 --- /dev/null +++ b/docker/ipv6-disable.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env sh +set -e + +DEFAULT_CONF_FILE="etc/nginx/conf.d/default.conf" + +if [ -f "/proc/net/if_inet6" ]; then + echo "info: IPv6 available." + exit 0 +fi + +echo "info: IPv6 not available!" +echo "info: Removing IPv6 lines from /$DEFAULT_CONF_FILE" +sed -i 's/\(listen\s*\[::\].*\)$/#\1 # Disabled IPv6/' /${DEFAULT_CONF_FILE}