I am trying to restrict access to PHPMyAdmin running on an Apache server to specific IP addresses. I want to allow access only from two specific IP addresses while denying access from all others. Using ubuntu 22.04 LTS and phpmyadmin version 5.1.1deb5ubuntu1
I have tried the following Apache configuration:
Alias /phpmyadmin /usr/share/phpmyadmin
<Directory /usr/share/phpmyadmin>
Options SymLinksIfOwnerMatch
DirectoryIndex index.php
<IfModule mod_php7.c>
php_admin_value upload_tmp_dir /var/lib/phpmyadmin/tmp
php_admin_value open_basedir /usr/share/phpmyadmin/:/usr/share/doc/phpmyadmin/:/etc/phpmyadmin/:/var/lib/phpmyadmin/:/usr/share/php/:/usr/share/javascript/
</IfModule>
Order Deny,Allow
Deny from All
Allow from xxxx.xxxx.100.100
Allow from xxxx.xxxx.113.12
</Directory>
# Disallow web access to directories that don't need it
<Directory /usr/share/phpmyadmin/templates>
Require all denied
</Directory>
<Directory /usr/share/phpmyadmin/libraries>
Require all denied
</Directory>
However, this configuration does not seem to work as expected. Even after specifying the allowed IP addresses, access to PHPMyAdmin is still denied from all IP addresses. I have also tried removing the Deny from All line, which allows access from any IP address, but I want to restrict access to only the specified IP addresses.
How can I properly configure Apache to restrict access to PHPMyAdmin to only the specified IP addresses?