nginx-proxy-auto-docker/htpasswd_generator.tmpl

16 lines
No EOL
344 B
Bash

#!/bin/sh
mkdir -p /etc/nginx/htpasswd
{{ range $host, $containers := groupByMulti $ "Env.VIRTUAL_HOST" "," }}
{{ $host := trim $host }}
{{ $htpasswd := or (first (groupByKeys $containers "Env.VHOST_HTPASSWD")) "" }}
if [ ! -z '{{$htpasswd}}' ]
then
echo '{{ $htpasswd }}' > /etc/nginx/htpasswd/{{ $host }}
fi
{{ end }}
nginx -s reload