setup_basic-auth.sh 435 B

1234567891011121314151617
  1. #!/bin/bash -e
  2. [ $# -eq 0 ] && { echo "Usage: $0 <vhost> <user> <pass>"; exit 1; }
  3. vhost=$1
  4. user=$2
  5. pass=$3
  6. htpasswd_dir=/opt/docker/proxy/data/htpasswd/
  7. mkdir -p $htpasswd_dir
  8. htpasswd="$user"":"`echo $pass | openssl passwd -stdin`
  9. echo " Writing:"
  10. echo " --> $htpasswd"
  11. echo " --> into: $htpasswd_dir$vhost"
  12. echo $htpasswd > $htpasswd_dir$vhost
  13. # Restart so the password file is read by nginx
  14. docker restart reverse-proxy