Add Password protect instance with nginx
32
Password-protect-instance-with-nginx.md
Normal file
32
Password-protect-instance-with-nginx.md
Normal file
@@ -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
|
||||
```
|
||||
Reference in New Issue
Block a user