From 53b265455661fe0a6fc986ad589d6ecfd911847c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Thu, 3 Nov 2022 14:03:13 +0100 Subject: [PATCH] web: auto-detect nginx resolver Take it from /etc/resolv.conf in case it wasn't provided via the env variable. Fixes: https://github.com/jitsi/docker-jitsi-meet/issues/1430 --- web/rootfs/defaults/nginx.conf | 4 +++- web/rootfs/etc/cont-init.d/10-config | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/web/rootfs/defaults/nginx.conf b/web/rootfs/defaults/nginx.conf index 8626887..adf14f9 100644 --- a/web/rootfs/defaults/nginx.conf +++ b/web/rootfs/defaults/nginx.conf @@ -26,7 +26,9 @@ http { client_max_body_size 0; - resolver {{ .Env.NGINX_RESOLVER | default "127.0.0.11" }}; + {{ if .Env.NGINX_RESOLVER }} + resolver {{ .Env.NGINX_RESOLVER }}; + {{ end -}} include /etc/nginx/mime.types; types { diff --git a/web/rootfs/etc/cont-init.d/10-config b/web/rootfs/etc/cont-init.d/10-config index 424ae87..2e02aff 100644 --- a/web/rootfs/etc/cont-init.d/10-config +++ b/web/rootfs/etc/cont-init.d/10-config @@ -63,6 +63,13 @@ if [[ $DISABLE_HTTPS -ne 1 ]]; then fi 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:]]*$//") +fi + +echo "Using Nginx resolver: =$NGINX_RESOLVER=" + # copy config files tpl /defaults/nginx.conf > /config/nginx/nginx.conf