Skip to content

Commit

Permalink
web: auto-detect nginx resolver
Browse files Browse the repository at this point in the history
Take it from /etc/resolv.conf in case it wasn't provided via the env
variable.

Fixes: #1430
  • Loading branch information
saghul committed Nov 3, 2022
1 parent 9fbb5bd commit 53b2654
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion web/rootfs/defaults/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 7 additions & 0 deletions web/rootfs/etc/cont-init.d/10-config
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 53b2654

Please sign in to comment.