From a0870d8d2a1ceaae317804c4de6cbc1f15a02b27 Mon Sep 17 00:00:00 2001 From: ASTER Date: Wed, 27 May 2026 11:59:58 +0000 Subject: [PATCH] Add Password protect instance with nginx --- Password-protect-instance-with-nginx.md | 32 +++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Password-protect-instance-with-nginx.md 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