⌘BABAKOV.NET Let's code!
100% [light] [ru]

Simple Site Access on Apache by Password

Example of organizing access to the site with a password through Apache.

First, we need to have Apache utilities installed: apache2-utils

If not installed, install. For Ubuntu, for example, like this:

sudo apt-get install apache2-utils



Create a file with user test and password:

sudo htpasswd -c /etc/apache2/.htpasswd test



Now in the file /etc/apache2/.htpasswd in encrypted form, understandable to Apache, lies information about the user and password.
Now add authentication for the selected host in site-enabled:

<VirtualHost *:8080>

<Location /> 
            Deny from all
            #Allow from (Здесь можно добавить IP с которых будет возможен вход без пароля)
            AuthUserFile /etc/apache2/.htpasswd # путь до файла apache с паролями
            AuthName authorization
            AuthType Basic
            Satisfy Any 
            require valid-user
</Location>
...
</VirtualHost>

Comments (0)

No comments yet.

Leave a comment
Comment
Images (up to 5 MB)
Your comment will appear after moderation.