Create a Username/Password which will be stored in ‘useraccess’, a file I just made up.
htpasswd -b -c useraccess username password
-b: allows password in command line rather than prompt -c: creates new passwd file, or rewrites and appends if the file already exists.
Now in the nginx config, under:
server {
location /protectedlocation {
Add the following
auth_basic "Message box title of password prompt";
auth_basic_user_file /path/to/useraccess;
Now restart nginx and go to the location you've just protected. Please comment if this was useful.

