Normally, if you create a folder on your site, you can access all the files inside it just by visiting the file’s URL. Sometimes however, you want to password protect directories in cPanel – either you’re testing a new design that you’re not ready to show the world, or it’s a staging area for your site. Or maybe you just want to prevent unauthorized access to sensitive parts your site. Like the “wp-admin” area of WordPress for example.
password protect
Password Protecting Directories With Nginx
The first thing you will need to do is create a file called .htpasswd (it doesn’t have to be named that way). The following command creates a new .htpasswd file and stores a record in it for user tom.
htpasswd -bc /var/www/yourdomain.com/.htpasswd tom password
To create another user:
htpasswd -b /var/www/yourdomain.com/.htpasswd john password