allow one .htpasswd file for all VIRTUAL_HOST’s

This commit is contained in:
Mark Wolff 2018-09-19 10:08:01 +02:00
parent e80fc0b304
commit 025e3a11cf

View file

@ -284,10 +284,13 @@ server {
proxy_pass {{ trim $proto }}://{{ trim $upstream_name }};
{{ end }}
{{ if (exists (printf "/etc/nginx/htpasswd/%s" $host)) }}
auth_basic "Restricted {{ $host }}";
auth_basic_user_file {{ (printf "/etc/nginx/htpasswd/%s" $host) }};
{{ 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}};
{{ else if (exists "/etc/nginx/vhost.d/default_location") }}
@ -331,9 +334,12 @@ server {
proxy_pass {{ trim $proto }}://{{ trim $upstream_name }};
{{ end }}
{{ if (exists (printf "/etc/nginx/htpasswd/%s" $host)) }}
auth_basic "Restricted {{ $host }}";
auth_basic_user_file {{ (printf "/etc/nginx/htpasswd/%s" $host) }};
{{ end }}
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}};
{{ else if (exists "/etc/nginx/vhost.d/default_location") }}