diff --git a/nginx-envtpl/Dockerfile b/nginx-envtpl/Dockerfile index 5a3ebbd..a0c5bd7 100644 --- a/nginx-envtpl/Dockerfile +++ b/nginx-envtpl/Dockerfile @@ -4,6 +4,7 @@ MAINTAINER Johannes Schickling "schickling.j@gmail.com" RUN apt-get update \ && apt-get install --no-install-recommends --no-install-suggests -y \ + openssl \ ca-certificates \ nginx-extras \ python-pip \ diff --git a/nginx-envtpl/entrypoint.sh b/nginx-envtpl/entrypoint.sh index 1b78983..c2c8483 100755 --- a/nginx-envtpl/entrypoint.sh +++ b/nginx-envtpl/entrypoint.sh @@ -8,4 +8,9 @@ else envtpl /etc/nginx/nginx.conf.tpl fi +if [[ ! -z $NGINX_AUTH_BASIC_USER && ! -z $NGINX_AUTH_BASIC_PASSWORD ]]; then + echo -n "$NGINX_AUTH_BASIC_USER:" > /etc/nginx/.htpasswd + openssl passwd -apr1 $NGINX_AUTH_BASIC_PASSWORD >> /etc/nginx/.htpasswd +fi + exec "$@"