Skip to content

Commit ac25171

Browse files
authored
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
1 parent 7281ed5 commit ac25171

File tree

1 file changed

+1
-1
lines changed
  • docker/rootfs/etc/services.d/nginx

1 file changed

+1
-1
lines changed

docker/rootfs/etc/services.d/nginx/run

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ chown root /tmp/nginx
2424

2525
# Dynamically generate resolvers file, if resolver is IPv6, enclose in `[]`
2626
# thanks @tfmm
27-
echo resolver "$(awk 'BEGIN{ORS=" "} $1=="nameserver" { sub(/%.*$/,"",$2); print ($2 ~ ":")? "["$2"]": $2}' /etc/resolv.conf);" > /etc/nginx/conf.d/include/resolvers.conf
27+
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
2828

2929
# Generate dummy self-signed certificate.
3030
if [ ! -f /data/nginx/dummycert.pem ] || [ ! -f /data/nginx/dummykey.pem ]

0 commit comments

Comments
 (0)