Switch from hardcoding quad9 to reading resolv.conf

This commit is contained in:
Andrew Godwin 2023-02-19 10:33:52 -07:00
parent 79aea1b8ba
commit aa592b496a
2 changed files with 7 additions and 3 deletions

View file

@ -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 '';

View file

@ -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 &