2
Password protect instance with nginx
ASTER edited this page 2026-05-27 12:00:55 +00:00
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
To add another user, run the same command but omit the -c. Example:
sudo htpasswd /etc/nginx/.htpasswd user2
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