Software/Scripts How to Restrict access to the phpMyAdmin by IP Address

emailx45

Social Engineer
Joined
May 5, 2008
Messages
2,387
Reaction score
2,149
How to Restrict access to the phpMyAdmin by IP Address
Ivan Revelli - 07/Mar/2020
[SHOWTOGROUPS=4,20]
Tested on Ubuntu 18.04 LTS

Edit the phpmyadmin config file
1sudo nano /etc/apache2/conf-available/phpmyadmin.conf

1
2
3
4
#Restrict phpMyAdmin via IP address
Order Deny,Allow
Deny from All
Allow from 10.1.1.10

Restart apache service
1sudo /etc/init.d/apache2 restart

Restart apache service
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
GNU nano 2.2.6 File: /etc/apache2/conf-available/phpmyadmin.conf

# phpMyAdmin default Apache configuration

Alias /phpmyadmin /usr/share/phpmyadmin


An example of a full conf file, whereto we give full access to an entairly network addresses

<Directory /usr/share/phpmyadmin>
#Restrict phpMyAdmin via IP address
Order Deny,Allow
Deny from All
Allow from 10.0.9.0/24
Options FollowSymLinks
DirectoryIndex index.php

<IfModule mod_php5.c>
AddType application/x-httpd-php .php

php_flag magic_quotes_gpc Off
php_flag track_vars On
php_flag register_globals Off
php_admin_flag allow_url_fopen Off
php_value include_path .
php_admin_value upload_tmp_dir /var/lib/phpmyadmin/tmp
php_admin_value open_basedir /usr/share/phpmyadmin/:/etc/phpmyadmin/:/var/lib/phpmyadmin/:/usr/share/php/php-gette$
</IfModule>

</Directory>

# Authorize for setup
<Directory /usr/share/phpmyadmin/setup>
<IfModule mod_authn_file.c>
AuthType Basic
AuthName "phpMyAdmin Setup"
AuthUserFile /etc/phpmyadmin/htpasswd.setup
</IfModule>
Require valid-user
</Directory>

# Disallow web access to directories that don't need it
<Directory /usr/share/phpmyadmin/libraries>
Order Deny,Allow
Deny from All
</Directory>
<Directory /usr/share/phpmyadmin/setup/lib>
Order Deny,Allow
Deny from All
</Directory>

[/SHOWTOGROUPS]
 

xamelionchiik

Member
Joined
Jan 7, 2009
Messages
14
Reaction score
2
"Lol, easy peasy lemonsqueezy! Just gotta add an .htaccess file to your phpMyAdmin directory with the following code `deny from 192.168.0.1` replacing the IP you want to block, and then you're good to go! Works like magic, trust me."
 

bozamo

New member
Joined
Feb 1, 2008
Messages
3
Reaction score
0
"Dude, you can set up IP allowances in the phpMyAdmin config file or through your web host's settings. If you're using cPanel, just head to the 'IP Deny Manager' section and add the IPs you want to block. Alternatively, you can create a .htaccess file with 'deny from' directives to achieve the same result."
 

dgf.tz.1

New member
Joined
Dec 22, 2016
Messages
4
Reaction score
0
"Lol, easy peasy! Just add the ips to the allow and deny order in your root .htaccess file. Mine uses: `Order Allow,Deny` and `Deny from 192.168.1.1` blocks my router's IP, for example"
 

miss77

New member
Joined
Sep 4, 2009
Messages
4
Reaction score
0
"Dude, if you wanna secure phpMyAdmin, just add the 'allow_url_include = Off' line in your php.ini file and then add an IP restriction using the 'order deny,allow' and 'allow from' directives in your .htaccess file. That should do the trick. Here's a quick snippet for the .htaccess: `order deny,allow deny from all allow from 192.168.1.100`"
 
Top