Skip to content

Commit

Permalink
option to override nginx resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
ronaldgrn committed May 13, 2021
1 parent 347cf5f commit fbd5a34
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ docker run -it \

`REDIS_PORT` - If using the redis adapter; the redis port. Defaults to 6379

`RESOLVER` - Nginx resolver. Useful for cases where we need to connect by hostname to a local redis server. Defaults to 8.8.8.8


## Advanced
Say we want to proxy a local Django server, then, in the Django project
Expand Down
2 changes: 1 addition & 1 deletion nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ http {
# default DNS servers, which can be found in /etc/resolv.conf. If your network
# is not IPv6 compatible, you may wish to disable IPv6 results by using the
# "ipv6=off" flag (like "resolver 8.8.8.8 ipv6=off").
resolver 8.8.8.8;
resolver {{ RESOLVER }};

# Initial setup tasks.
init_by_lua_block {
Expand Down
7 changes: 7 additions & 0 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ if [[ -z "${STORAGE_ADAPTER}" ]]; then
STORAGE_ADAPTER="file"
fi

if [[ -z "${RESOLVER}" ]]; then
# Should be one of 'file' or 'redis'
echo "RESOLVER env not provided. Defaulting to 8.8.8.8."
RESOLVER="8.8.8.8"
fi

if [ "${STORAGE_ADAPTER}" == "redis" ]; then
if [[ -z "${REDIS_HOST}" ]]; then
echo "REDIS_HOST env is required if using redis storage adapter."
Expand All @@ -35,6 +41,7 @@ fi
sed -i -e "s/{{ DNS_DOMAIN }}/${DNS_DOMAIN//\//\\/}/g" /usr/local/openresty/nginx/conf/nginx.conf
sed -i -e "s/{{ PROXY_PASS }}/${PROXY_PASS//\//\\/}/g" /usr/local/openresty/nginx/conf/nginx.conf
sed -i -e "s/{{ STORAGE_ADAPTER }}/${STORAGE_ADAPTER}/g" /usr/local/openresty/nginx/conf/nginx.conf
sed -i -e "s/{{ RESOLVER }}/${RESOLVER}/g" /usr/local/openresty/nginx/conf/nginx.conf
sed -i -e "s/{{ REDIS_HOST }}/${REDIS_HOST//\//\\/}/g" /usr/local/openresty/nginx/conf/nginx.conf
sed -i -e "s/{{ REDIS_PORT }}/${REDIS_PORT}/g" /usr/local/openresty/nginx/conf/nginx.conf

Expand Down

0 comments on commit fbd5a34

Please sign in to comment.