diff --git a/Password-protect-instance-with-nginx.md b/Password-protect-instance-with-nginx.md new file mode 100644 index 0000000..9487041 --- /dev/null +++ b/Password-protect-instance-with-nginx.md @@ -0,0 +1,32 @@ +The browser will prompt for a username and password when trying to access the site, which is useful for only sharing this information with specific individuals. + +Make sure apache2-utils is installed: + +``` +sudo apt install apache2-utils +``` + +Generate password file and add user1 - you will be prompted for the password to user1. Feel free to change user1 to any username you want. + +``` +sudo htpasswd -c /etc/nginx/.htpasswd user1 +``` + +Modify the site's configuration file. We have used default in other areas of the wiki, but your own may vary + +``` +sudo nano /etc/nginx/sites-available/default +``` + +Add the following lines into the server { } section + +``` +auth_basic "Authorization Required"; +auth_basic_user_file /etc/nginx/.htpasswd; +``` + +Reload nginx: + +``` +nginx -s reload +``` \ No newline at end of file