From b212dca060e1c9649ae1846af9518e6714f7250a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Tue, 15 Nov 2022 10:18:31 +0100 Subject: [PATCH] web: fix parsing IPv6 reolver addresses Fixes: https://github.com/jitsi/docker-jitsi-meet/issues/1437 --- web/rootfs/etc/cont-init.d/10-config | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/web/rootfs/etc/cont-init.d/10-config b/web/rootfs/etc/cont-init.d/10-config index 2e02aff149..f0e7ab2ac0 100644 --- a/web/rootfs/etc/cont-init.d/10-config +++ b/web/rootfs/etc/cont-init.d/10-config @@ -65,7 +65,25 @@ fi # Detect nameserver for Nginx, if not specified. if [[ -z "$NGINX_RESOLVER" ]]; then - export NGINX_RESOLVER=$(grep nameserver /etc/resolv.conf | cut -d" " -f2 | tr "\n" " " | sed -e "s/[[:space:]]*$//") + IP_LIST="" + + # Parse IPs in /etc/resolv.conf, taking into account IPv6 addresses need to be + # enclosed in square brackets for the Nginx config file. + while read -r line; do + if [[ $line =~ ^nameserver.* ]]; then + IP=$(echo $line | cut -d" " -f2) + COLONS=$(echo $IP | tr -dc ":" | awk '{ print length '}) + if [[ $COLONS -ge 2 ]]; then + IP="[$IP]" + fi + if [[ ! "$IP_LIST" = "" ]]; then + IP_LIST+=" " + fi + IP_LIST+="$IP" + fi + done < <(cat /etc/resolv.conf) + + export NGINX_RESOLVER=$IP_LIST fi echo "Using Nginx resolver: =$NGINX_RESOLVER="