You can restrict access to your website or some parts of it by implementing a username/password authentication. Usernames and passwords are taken from a file created and populated by a password file creation tool, for example, apache2-utils.

Creating a Password File

Create additional user-password pairs. Omit the -c flag because the file already exists

Nginx configuration

location /public/ {
    auth_basic off;
}

}

Apache/httpd basic configuration

<Directory "/var/www/html">
    AuthType Basic
    AuthName "Restricted Content"
    AuthUserFile /etc/httpd/.htpasswd
    Require valid-user
</Directory>

</VirtualHost>

Apache/httpd with proxypass

&lt;Location /&gt;
    AuthType Basic
    AuthName "Restricted Content"
    AuthUserFile /etc/httpd/.htpasswd
    Require valid-user
&lt;/Location&gt;

</VirtualHost>