Question
How to disable a ModSecurity rule on a per user basis?
Answer
A ModSecurity rule may be impacting a user, and you want to only disable the rule for that just user. User-level Apache include files used on a cPanel server can be used to disable the rule.
Note: In the following procedure, $cpuser must be replaced with the cPanel user's username.
- Access the server's command line as the
rootuser via SSH or Terminal in WHM. -
Use the following command to create the cPanel user's include folders:
# mkdir -p /etc/apache2/conf.d/userdata/std/2_4/$cpuser /etc/apache2/conf.d/userdata/ssl/2_4/$cpuser
-
Create the user's configuration file:
# touch /etc/apache2/conf.d/userdata/std/2_4/$cpuser/modsec.conf
- Open the file in your preferred text editor.
-
Add the following lines to the file:
CONFIG_TEXT: <LocationMatch .*>
SecRuleRemoveById $ruleID
</LocationMatch>Note:
$ruleIDmust be replaced with the ModSecurity rule ID to be disabled. - Save the changes and exit the text editor.
-
Copy the configuration to the user's
sslfolder:# cp -av /etc/apache2/conf.d/userdata/std/2_4/$cpuser/modsec.conf /etc/apache2/conf.d/userdata/ssl/2_4/$cpuser/modsec.conf
-
Rebuild the Apache configuration:
# /scripts/rebuildhttpdconf
-
Restart the web server.
# /scripts/restartsrv_httpd --hard
Additional Resources
How to use Apache includes to add configuration directives to all VirtualHosts server-wide
How to use Apache Includes to add Configuration Directives to a specific domain's VirtualHost
Comments
0 comments
Article is closed for comments.