From ac2517142051e215f031d7cdcbb4ef21d5e5f93d Mon Sep 17 00:00:00 2001 From: Omer Cohen Date: Wed, 16 Feb 2022 09:31:56 +0200 Subject: [PATCH] Update resolvers.conf to break dns cache By default, nginx caches answers using the TTL value of a response. In a dynamic environment containers can get recreated with new IPs, reducing the validity of the cache allows refreshing these IPs https://nginx.org/en/docs/http/ngx_http_core_module.html#resolver --- docker/rootfs/etc/services.d/nginx/run | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/rootfs/etc/services.d/nginx/run b/docker/rootfs/etc/services.d/nginx/run index 508b7d73..51ca5ea1 100755 --- a/docker/rootfs/etc/services.d/nginx/run +++ b/docker/rootfs/etc/services.d/nginx/run @@ -24,7 +24,7 @@ chown root /tmp/nginx # Dynamically generate resolvers file, if resolver is IPv6, enclose in `[]` # thanks @tfmm -echo resolver "$(awk 'BEGIN{ORS=" "} $1=="nameserver" { sub(/%.*$/,"",$2); print ($2 ~ ":")? "["$2"]": $2}' /etc/resolv.conf);" > /etc/nginx/conf.d/include/resolvers.conf +echo resolver "$(awk 'BEGIN{ORS=" "} $1=="nameserver" { sub(/%.*$/,"",$2); print ($2 ~ ":")? "["$2"]": $2}' /etc/resolv.conf) valid=10s;" > /etc/nginx/conf.d/include/resolvers.conf # Generate dummy self-signed certificate. if [ ! -f /data/nginx/dummycert.pem ] || [ ! -f /data/nginx/dummykey.pem ]