ModSecurity custom rules

tomputer

Verified User
Joined
Apr 5, 2016
Messages
46
Location
The Netherlands
When ModSecurity is build with Custombuid, a directory for config files is created:
Code:
/etc/modsecurity.d/
Config files in this directory are loaded in the httpd-modsecurity.conf file:
Code:
IncludeOptional /etc/modsecurity.d/*.conf
However, when (re)building ./build modsecurity, all config files are removed:
Code:
[line 14739]: rm -f /etc/modsecurity.d/*
Custombuild will (re)install the default rules (comodo) but all custom conf files are removed.

I would like to suggest to change the remove line to something like this:
Code:
rm /etc/modsecurity.d/comodo_rules.conf.main

This way we can install our custom configs and rules also in /etc/modsecurity.d

My current workaround is: chattr +i /etc/modsecurity.d/custom.conf
 
It's been a while since I looked at this, but can you use the custom/modsecurity/conf folder in custombuild for this?

You'll likely need to create the folder.
 
It's been a while since I looked at this, but can you use the custom/modsecurity/conf folder in custombuild for this?
That doesn't work. There is also no such folder in /custombuild/configure/

As far as i can see in build, it downloads the source and config files. There is only: /custombuild/configure/ap2/configure.modsecurity
 
The folder should be /usr/local/directadmin/custombuild/custom/modsecurity/conf (provided your custombuild is at /usr/local/directadmin/custombuild).

It wont' exist by default.

You were in the build shell script, so grep for 'modsecurity/conf' and you'll see what I'm talking about.
 
Seems i forgot to add the conf directory. It does indeed work now, thanks!

Build also describes it:

"Add custom rules to custom/modsecurity/conf, they'd be added automatically to /etc/modsecurity.d after './build modsecurity' or './build modsecurity_rules' is ran."
 
Back
Top