Apache拒绝外部文件中的ip列表

r19*_*156 4 apache

我想维护一个文件,其中包含一个阻止使用网站的ip列表.我理解deny from可用于实现此目的(例如Deny from 127.0.0.1 10.0.0.1 some.other.ip.address).

但是,我想要一个外部文件,以便无权访问配置的个人可以使用ip更新txt文件,然后将其包含在deny中.

有没有人对如何实现这一点有任何建议?任何帮助都非常有用.

Wil*_*nly 7

查看Apache Include指令:

http://httpd.apache.org/docs/2.2/mod/core.html#include

您可以创建一个包含拒绝列表的单独配置文件,并包含在任何其他配置文件中,即站点中可用的站点.以下示例用法:

在/etc/apache2/sites-enabled/yoursite.conf中

<VirtualHost *:80>
...

Include /etc/apache2/sites-access/yoursite.conf

...
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

在/etc/apache2/sites-access/yoursite.conf中

order allow,deny
deny from 10.0.0.1
allow from all
Run Code Online (Sandbox Code Playgroud)