简体   繁体   English

如何在多个虚拟主机中包含相同的modsecurity规则而不更改每个规则和每个主机的ID?

[英]How to include same modsecurity rules in multiple virtual hosts without changing the id for each rule and each host?

I have multiple virtual hosts with Modsecurity enabled. 我有多个启用了Modsecurity的虚拟主机。 I want to assign multiple OWASP rules (from the base_rules folder) like SQL injection to multiple virtual hosts. 我想将多个OWASP规则 (来自base_rules文件夹)分配给多个虚拟主机,例如SQL注入。 I have included them in my virtual host files, but I get the following message when I reload apache: 我已经将它们包含在我的虚拟主机文件中,但是当我重新加载apache时会收到以下消息:

ModSecurity: Found another rule with the same id Action '-t' failed. 

The Apache error log may have more information.

How can I include these base rules in multiple virtual hosts without changing the id for each rule? 如何在不更改每个规则的ID的情况下将这些基本规则包含在多个虚拟主机中? The server is meant to proxy to a lot of virtual hosts, so changing the ID for each rule and each host would be a lot of work to do manually. 该服务器旨在代理许多虚拟主机,因此,更改每个规则和每个主机的ID将需要手动完成大量工作。

Include them at the server level and not the vhost level. 在服务器级别而不是虚拟主机级别包括它们。

If you don't need them for certain vhosts then you can write ModSecurity rules to exclude some or all of the rules based on the incoming host header. 如果某些虚拟主机不需要它们,则可以编写ModSecurity规则以根据传入的主机头排除某些或所有规则。

Including the rules at VHOST level did the trick. 包括VHOST级别的规则就可以了。
The config which causes the error: 导致错误的配置:

IncludeOptional folder_to_rules/modsecurity_crs_41_xss_attacks.conf
<VirtualHost *:80>
    ServerName example.com
    SecRuleEngine On

</VirtualHost>

Solution: 解:

<VirtualHost *:80>
    ServerName example.com
    SecRuleEngine On
    IncludeOptional folder_to_rules/modsecurity_crs_41_xss_attacks.conf
</VirtualHost>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM