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?
我想限制phpmyadmin只访问某些IP地址。我无法更改服务器配置,我现在无法更改我的httpd conf文件。有没有办法在应用程序级别完成此操作?
1 个解决方案
#1
1
I've noticed that this is a duplicate of this: How to restrict access to phpmyadmin?
我注意到这与此重复:如何限制对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.
我发现实现这一目标的方法是进入phpmyadmin的config.inc.php。您可以在phpmyadmin目录的根目录中找到它。
$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:
编辑:如果你是一个代理,我认为大多数生产服务器。您还应该为HTTP_X_FORWARDED_FOR设置可信代理,如下所示:
$cfg['TrustedProxies'] = array('*PROXY_IP_HERE*' => 'HTTP_X_FORWARDED_FOR',);
#1
1
I've noticed that this is a duplicate of this: How to restrict access to phpmyadmin?
我注意到这与此重复:如何限制对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.
我发现实现这一目标的方法是进入phpmyadmin的config.inc.php。您可以在phpmyadmin目录的根目录中找到它。
$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:
编辑:如果你是一个代理,我认为大多数生产服务器。您还应该为HTTP_X_FORWARDED_FOR设置可信代理,如下所示:
$cfg['TrustedProxies'] = array('*PROXY_IP_HERE*' => 'HTTP_X_FORWARDED_FOR',);