Re: How to configure ModSecurity on CentOS 8?

Ervin Hegedüs <[email protected]> Tue, 2 Mar 2021 21:13:45 +0100
Newsgroups gmane.comp.apache.mod-security.user
Message-ID <[email protected]>
Hi Jason,

On Tue, Mar 02, 2021 at 06:55:51PM +0000, Jason Long wrote:
> I found two files:
> 
> 1- /etc/httpd/conf.modules.d/10-mod_security.conf 
> 2- /etc/httpd/conf.d/mod_security.conf
> 
> The content of the first file is :
> 
> $ cat /etc/httpd/conf.modules.d/10-mod_security.conf 
> LoadModule security2_module modules/mod_security2.so
> 
> <IfModule !mod_unique_id.c>
>     LoadModule unique_id_module modules/mod_unique_id.so
> </IfModule>
> 
> And the content of the second file is :
> https://paste.ubuntu.com/p/Rtz6jRrwzT/
> 
> I don't know the difference between of the two files :(

I assume these directories came from default installation, which
means the Apache had set up that reads the necessary modules from
the directory /etc/httpd/conf.modules.d/, and the configuration
files from /etc/httpd/conf.d/. There must be two directives which
reads these directories, eg:

IncludeOptional /etc/httpd/conf.modules.d/*.conf
IncludeOptional /etc/httpd/conf.d/*.conf

or something similar...


/etc/httpd/conf.modules.d/10-mod_security.conf - this files loads
the mod_security Apache module. By this Apache will be able to
work as a WAF.


/etc/httpd/conf.d/mod_security.conf - this file is a
configuration file, in other words, this file sets up mod_security
module, tells to module how should it works.

The first 49 lines contains the general settings - for more info,
please check this page:

https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual-(v2.x)

Take a look to these lines:

52.	IncludeOptional modsecurity.d/*.conf
53.	IncludeOptional modsecurity.d/activated_rules/*.conf
54.	IncludeOptional modsecurity.d/local_rules/*.conf

These lines loads the rule set. On the last link I given you can
find so many usefull information about rules. The Apache's
IncludeOptional directive tells to Apache that read the directory
given that name, load the files with name the given pattern
(*.conf) - if there isn't any file with name *.conf, it's no
problem.

I think I think I think the parent modsecurity.d/ directory above
should be under /etc/httpd, or /etc/httpd/conf.d/ - just try it.
If Apache doesn't found the files, you will see in the error.log.

The order of loading of files is very important.

You have to copy the CRS rules/ directory content into the
activated_rules/ directory. I think the crs-setup.conf must be
copied under modsecurity.d/ directly. The local_rules/ can be
empty.

Because the SecRuleEngine is On in your setup
(10-mod_security.conf), and audit.log had configured, you have to
see any attack in that log, and in your error.log.


Hope this helps.


a.



_______________________________________________
mod-security-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mod-security-users
Commercial ModSecurity Rules and Support from Trustwave's SpiderLabs:
http://www.modsecurity.org/projects/commercial/rules/
http://www.modsecurity.org/projects/commercial/support/