From aa592b496a8f98ac3caaa822d04d2eba404852eb Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Sun, 19 Feb 2023 10:33:52 -0700 Subject: [PATCH] Switch from hardcoding quad9 to reading resolv.conf --- docker/nginx.conf.d/default.conf.tpl | 2 +- docker/run.sh | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/docker/nginx.conf.d/default.conf.tpl b/docker/nginx.conf.d/default.conf.tpl index 36b73d0..8ec1e23 100644 --- a/docker/nginx.conf.d/default.conf.tpl +++ b/docker/nginx.conf.d/default.conf.tpl @@ -74,7 +74,7 @@ server { internal; # Reconstruct the remote URL - resolver 9.9.9.9 149.112.112.112 ipv6=off; + resolver __NAMESERVER__ valid=10s; # Unset Authorization and Cookie for security reasons. proxy_set_header Authorization ''; diff --git a/docker/run.sh b/docker/run.sh index af3ebb6..be233a0 100644 --- a/docker/run.sh +++ b/docker/run.sh @@ -1,8 +1,12 @@ #!/bin/bash -# Set up cache size +# Set up cache size and nameserver subs CACHE_SIZE="${TAKAHE_NGINX_CACHE_SIZE:-1g}" -sed s/__CACHESIZE__/${CACHE_SIZE}/g /etc/nginx/conf.d/default.conf.tpl > /etc/nginx/conf.d/default.conf +NAMESERVER=`cat /etc/resolv.conf | grep "nameserver" | awk '{print $2}' | tr '\n' ' '` +if [ -z "$NAMESERVER" ]; then + NAMESERVER="9.9.9.9 149.112.112.112" +fi +sed "s/__CACHESIZE__/${CACHE_SIZE}/g" /etc/nginx/conf.d/default.conf.tpl | sed "s/__NAMESERVER__/${NAMESERVER}/g" > /etc/nginx/conf.d/default.conf # Run nginx and gunicorn nginx &