Skip to content
This repository was archived by the owner on Nov 5, 2022. It is now read-only.

Commit 6f66d0b

Browse files
committed
Add htpasswd support to pathCount>1 case
Currently uses the same htpasswd for all services behind a hostname, but it could be desirable to allow different htpasswd for different paths
1 parent 0c94dc4 commit 6f66d0b

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

nginx.tmpl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ server {
138138
{{ $suffix := printf "-%s" $sum }}
139139
location {{ $path }} {
140140
proxy_pass http://{{ $host }}{{ $suffix }};
141+
{{ if (exists (printf "/etc/nginx/htpasswd/%s" $host)) }}
142+
auth_basic "Restricted {{ $host }}";
143+
auth_basic_user_file {{ (printf "/etc/nginx/htpasswd/%s" $host) }};
144+
{{ end }}
141145
}
142146
{{ end }}
143147
{{ end }}
@@ -165,6 +169,10 @@ server {
165169
{{ $suffix := printf "-%s" $sum }}
166170
location {{ $path }} {
167171
proxy_pass http://{{ $host }}{{ $suffix }};
172+
{{ if (exists (printf "/etc/nginx/htpasswd/%s" $host)) }}
173+
auth_basic "Restricted {{ $host }}";
174+
auth_basic_user_file {{ (printf "/etc/nginx/htpasswd/%s" $host) }};
175+
{{ end }}
168176
}
169177
{{ end }}
170178
{{ end }}

0 commit comments

Comments
 (0)