From b61b46d1c068e67de47a5ae9dbe1b12d6d097c22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Constantin=20Wildf=C3=B6rster?= Date: Tue, 4 Feb 2020 16:30:15 +0100 Subject: [PATCH] =?UTF-8?q?allow=20one=20.htpasswd=20file=20for=20all=20VI?= =?UTF-8?q?RTUAL=5FHOST=E2=80=99s=20@mark-wff?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nginx.tmpl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/nginx.tmpl b/nginx.tmpl index 374fabe..d986d76 100644 --- a/nginx.tmpl +++ b/nginx.tmpl @@ -353,10 +353,12 @@ server { proxy_pass {{ trim $proto }}://{{ trim $container.Name }}; {{ end }} {{ end }} - {{ if (exists (printf "/etc/nginx/htpasswd/%s" $host)) }} auth_basic "Restricted {{ $host }}"; auth_basic_user_file {{ (printf "/etc/nginx/htpasswd/%s" $host) }}; + {{ else if (exists ("/etc/nginx/htpasswd/.htpasswd")) }} + auth_basic "Restricted {{ $host }}"; + auth_basic_user_file {{ "/etc/nginx/htpasswd/.htpasswd" }}; {{ end }} {{ if (exists (printf "/etc/nginx/vhost.d/%s_location" $host)) }} include {{ printf "/etc/nginx/vhost.d/%s_location" $host}}; @@ -435,6 +437,9 @@ server { {{ if (exists (printf "/etc/nginx/htpasswd/%s" $host)) }} auth_basic "Restricted {{ $host }}"; auth_basic_user_file {{ (printf "/etc/nginx/htpasswd/%s" $host) }}; + {{ else if (exists ("/etc/nginx/htpasswd/.htpasswd")) }} + auth_basic "Restricted {{ $host }}"; + auth_basic_user_file {{ "/etc/nginx/htpasswd/.htpasswd" }}; {{ end }} {{ if (exists (printf "/etc/nginx/vhost.d/%s_location" $host)) }} include {{ printf "/etc/nginx/vhost.d/%s_location" $host}};