Create a Username/Password which will be stored in ‘useraccess’, a file I just made up.
htpasswd -b -c useraccess username password
1 2 |
-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:
1 |
server { |
1 |
location /protectedlocation { |
1 |
Add the following |
auth_basic "Message box title of password prompt";
auth_basic_user_file /path/to/useraccess;
1 |
Now restart nginx and go to the location you've just protected. Please comment if this was useful. |