Nginx Password Protect a website
To password protect a web site, you need to install htpasswd utility. On Ubuntu/Debian, you can install it with command
1 |
apt install apache2-utils -y |
Now create a password file with command
1 |
htpasswd -c /etc/nginx/.htpasswd USER_NAME_HERE |
It will ask for password.
Edit configuration file for your web site and add following in the server entry for the web site.
1 2 |
auth_basic "Members Only"; auth_basic_user_file /etc/nginx/.htpasswd; |
Restart Nginx.
1 |
systemctl restart nginx |
Now on visiting the web site, you will be asked to enter username and password.
If you need to allow SSL renewals, then see SSL Renewal On Nginx Password Protected site
See Nginx