Disable Apache Directory /phpmyadmin Based on Subnet

From my CounterStrike Global Offence setup, I realized that hosting the HLStats server online also was hosting my phpmyadmin directory as well.  As exposing the database to the outside world is very undesirable, a simple change the the Apache sites-enabled directory on Ubuntu 14.04 corrected the issue.

First, the goal was to allow authenticated client networks to access the directory. To do this in Ubuntu 14.04, we will browse to the “/etc/apache2/conf-enabled” directory.  Within the file, we will edit the /usr/share/phpmyadmin directory and add the 3 lines:

Order Deny,Allow
Deny from All
Allow from 192.168.1.0/24 192.168.7.0/24

The above syntax will allow networks 192.168.1.0/24 and 192.168.7.0/24 to access the directory, but everything else will be denied.  After saving the configuration, we will want to restart Apache by issuing “sudo service apache2 restart”.  The screen shot of the steps is listed below.

Commands Used to Block Unauthenticated HTTP Access to phpmyadmin

Commands Used to Block Unauthenticated HTTP Access to phpmyadmin

After restarting Apache using the steps above, the web page is now blocked from the internet.  The HLStats web page is also still available as desired.

Blocked phpmyadmin URL

Blocked phpmyadmin URL

Leave a Reply

Your email address will not be published. Required fields are marked *