0

我已经在 apache2 中使用 Reverse Proxy+Mod Security 设置了虚拟主机配置。但它重叠,重新启动 apache2 时不会出现任何错误,但第二个虚拟主机配置与第一个重叠。

第一个工作正常。

我的虚拟主机配置如下:

NameVirtualHost 192.168.1.101:80
<VirtualHost 192.168.1.101:80>

ServerName 124.125.252.31

DocumentRoot /var/www

<Proxy *>
Order deny,allow
Allow from all
</Proxy>

ProxyRequests Off

ProxyPass /asd http://124.125.252.31/
ProxyPassReverse /asd http://124.125.252.31/

<Location /asd>
Order deny,allow
Allow from all
</Location>

Include /etc/apache2/rules/modsecurity_crs_10_config.conf
Include /etc/apache2/rules/base_rules/*.conf

</VirtualHost>


<VirtualHost 192.168.1.101:80>

ServerName 124.125.252.32

DocumentRoot /var/www

<Proxy *>
Order deny,allow
Allow from all
</Proxy>

ProxyRequests Off

ProxyPass /qwe http://124.125.252.32/
ProxyPassReverse /qwe http://124.125.252.32/

<Location /qwe>
Order deny,allow
Allow from all
</Location>

Include /etc/apache2/rules/modsecurity_crs_10_config.conf
Include /etc/apache2/rules/base_rules/*.conf

</VirtualHost>
4

1 回答 1

0

根据最新的 ModSecurity 参考手册,在配置指令部分:

大多数 ModSecurity 指令都可以在各种 Apache Scope 指令中使用,例如 VirtualHost、Location、LocationMatch、Directory 等……但是,还有其他指令只能在主配置文件中使用一次。此信息在下面的范围部分中指定。使用给定指令的第一个版本在下面的版本部分中给出。这些规则以及核心规则文件应该包含在 httpd.conf 文件之外的文件中,并使用 Apache“包含”指令调用。

我猜您的配置中的以下行应该直接包含在您的主 httpd.conf 文件中:

Include /etc/apache2/rules/modsecurity_crs_10_config.conf

而且我猜测可以在您的虚拟主机中插入以下行:

Include /etc/apache2/rules/base_rules/*.conf

但我可能错了。只是此在线 crs_10_config 示例中的某些指令具有指定为“Main”而不是“Any”的范围(例如 SecComponentSignature 仅举一个例子)。

是什么让你意识到它们重叠?你有日志吗?

于 2012-03-31T04:43:57.420 回答