Add Password protect instance with nginx

2026-05-27 11:59:58 +00:00
parent 8889743732
commit a0870d8d2a

@@ -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
```