To lock down an Nginx website with a username and password.
- add the following to your Nginx configuration: auth_basic "Restricted Area"; auth_basic_user_file /home/forge/default/.htpasswd;
- Next, create a .htpasswd in your sites directory. In the example above the site, directory name would be "default".
- You need to md5 your password I suggest using something like this: http://www.htaccesstools.com/htpasswd-generator/
- For example, I generated username and password: codetime:$apr1$8v.xDamX$GNzJXTIGcHPyU3CeITxEE1 The username is "codetime", the password, in this case, is also "codetime" but its been md5 hashed.
- Paste it into the .htpasswd file and then save.
- You may need to restart your server/nginx