How to restrict access to the administrative panel?
Access restriction by IP
The Administrative Panel will be available only from certain IP addresses or subnets. For example, address range 10.118.41.0/24.
For example, to allow access to the administrative panel for the address range 10.118.41.0/24, the file
<VirtualHost 127.0.0.1:88> DocumentRoot /var/www <Directory /var/www/stalker_portal/> Options -Indexes -MultiViews AllowOverride ALL Require all granted </Directory> <Directory /var/www/stalker_portal/server/adm/> Order Deny,Allow Deny from All Allow from 10.118.41.0/24 </Directory> <Directory /var/www/stalker_portal/server/administrator/> Order Deny,Allow Deny from All Allow from 10.118.41.0/24 </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
where
Restart
service apache2 restart
The connection of additional authorization using the .htpasswd utility
Install the package
apt-get install apache2-utils
Generate a password file for the user:
htpasswd -c /etc/apache2/.htpasswd username
As a result, a file will be created in which the user login (username) will be specified, having access to the directory
The file
<VirtualHost 127.0.0.1:88> DocumentRoot /var/www <Directory /var/www/stalker_portal/> Options -Indexes -MultiViews AllowOverride ALL Require all granted </Directory> <Directory /var/www/stalker_portal/server/adm/> AuthType Basic AuthName "Restricted Content" AuthUserFile /etc/apache2/.htpasswd Require valid-user </Directory> <Directory /var/www/stalker_portal/server/administrator/> AuthType Basic AuthName "Restricted Content" AuthUserFile /etc/apache2/.htpasswd Require valid-user </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
Restart
service apache2 restart