george smiley
george smiley

Reputation: 27

Restrict phpmyadmin access in the application itself

I would like to restrict the phpmyadmin access only to certain IP addresses. I cannot change the server configuration and I'm not in a position right now to change my httpd conf files. Is there a way to accomplish this in application level?

Upvotes: 1

Views: 711

Answers (1)

turntwo
turntwo

Reputation: 2520

I've noticed that this is a duplicate of this: How to restrict access to phpmyadmin?

But since my answer hasn't been given there yet here's what I think:

I've found that a way to accomplish this is to get into phpmyadmin's config.inc.php. You can find that in the root directory of the phpmyadmin directory.

$cfg['Servers'][$i]['AllowDeny']['order'] = 'deny,allow';
$cfg['Servers'][$i]['AllowDeny']['rules'] = array(
   'deny % from all', 

   'allow % from 127.0.0.1', 
   'allow % from ::1',
   'allow % from *YOUR_IP_ADDRESS_HERE*',
);

Edit: If you're behind a proxy, which I think most production servers are. You should also set the trusted proxies for HTTP_X_FORWARDED_FOR like so:

$cfg['TrustedProxies'] = array('*PROXY_IP_HERE*' => 'HTTP_X_FORWARDED_FOR',);

Upvotes: 1

Related Questions