# How to protect the site with a password

### Creating a File with Username and Password

Log into the Shell client in ISPmanager as the <mark style="color:red;">root user</mark>.

<figure><img src="https://3137668309-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwgP5ZE7DnnlT9DQMSCQz%2Fuploads%2Fgit-blob-9316345f48ca4ccee5ca43dc99868affe22ac1cc%2Fimage%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)_eng.png?alt=media" alt=""><figcaption></figcaption></figure>

Run the following command, specifying the username (in this example, we'll use the username sysadmin):\
`sh -c "echo -n 'sysadmin:' >> /etc/nginx/.htpasswd"`

<figure><img src="https://3137668309-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwgP5ZE7DnnlT9DQMSCQz%2Fuploads%2Fgit-blob-801298f386c903a37806750bc9e279a438ff05b9%2Fimage%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)_eng.png?alt=media" alt=""><figcaption></figcaption></figure>

Next, run the command to encrypt the access password:\
`sh -c "openssl passwd -apr1 >> /etc/nginx/.htpasswd"`

<figure><img src="https://3137668309-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwgP5ZE7DnnlT9DQMSCQz%2Fuploads%2Fgit-blob-77e701984c5a479f1fa309d98e4aeaa9f596fbe6%2Fimage%20(2)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)_eng.png?alt=media" alt=""><figcaption></figcaption></figure>

**After this, the system will prompt you to enter and confirm the password—please provide them.**

The setup for the username and password file is complete.

### Configuring the Nginx Configuration File:

As the root user, go to the "Sites" tab and select "Configuration files" from the menu.

<figure><img src="https://github.com/armydrawer/premium-translate/blob/main/en/.gitbook/assets/image%20(5)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)_eng.png" alt=""><figcaption></figcaption></figure>

In the configuration file, locate the location block within the server ssl block (at the end of the file) and insert the following lines:

```
allow 123.123.123.123;
deny all;

auth_basic "Restricted Access";
auth_basic_user_file /etc/nginx/.htpasswd;

satisfy any;
```

<figure><img src="https://3137668309-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwgP5ZE7DnnlT9DQMSCQz%2Fuploads%2Fgit-blob-ed74f41ff33368384a4f2c29ab2d8eb786431091%2Fimage%20(2178)_eng.png?alt=media" alt=""><figcaption></figcaption></figure>

**The IP address 123.123.123.123 is the server's address (web); it will be different in your case!**

After that, save the changes and reload the server.

<figure><img src="https://3137668309-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwgP5ZE7DnnlT9DQMSCQz%2Fuploads%2Fgit-blob-ae3f2b10cb907893401bc76a708c7f44d8b0a132%2Fimage%20(2177)_eng.png?alt=media" alt=""><figcaption></figcaption></figure>

To disable the password protection for the website, remove the lines (2), save the changes, and reload the server.
