Disable Mod-security2 for a Domain in cPanel
- Category : Linux Helpline (Easy Guide)
- Posted on : Apr 15, 2019
- Views : 1,623
- By : Hagen V.
First of all we can’t block mod_security2 via .htaccess on domain basis . So never put .htaccess mod-security rules. You have to disable it in the vhost configuration in apache.
In cpanel server it will be as follows,
1) Create a custom vhost configuration file called mod-security.conf in the following location.
# mkdir -pv /usr/local/apache/conf/userdata/std/2/CPUSER/DOMAINNAME/
# touch /usr/local/apache/conf/userdata/std/2/CPUSER/DOMAINNAME/mod-security.conf
2) Now add the following lines to this file
#################################
<IfModule mod_security2.c>
SecRuleEngine Off
</IfModule>
################################
The above will disable the modsecurity rule for a particulr domain name . If you only need to disable the rules for a particlur folder , please add the rules as follows,
######################
<LocationMatch specify_the_path_here>
<IfModule mod_security2.c>
SecRuleEngine Off
</IfModule>
</LocationMatch>
#######################
If you only need to disable a particular rule , the create the file with the following ,
#########################3
<IfModule mod_security2.c>
SecRuleRemoveById give_ruleID_here
</IfModule>
##########################
3) Now as the final step please ensure this custom vhost using the following command in cpanel servers,
# /scripts/ensure_vhost_includes –user=CPUSERNAME
This script will uncomment the following line in apache configuration. It will customize the virtual host to use the particular include file and will restart apache.
##############
Include “/usr/local/apache/conf/userdata/std/2/CPUSER/DOMAINNAME/*.conf”
#################
Categories
Subscribe Now
10,000 successful online businessmen like to have our content directly delivered to their inbox. Subscribe to our newsletter!Archive Calendar
Sat | Sun | Mon | Tue | Wed | Thu | Fri |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 |
Recent Articles
-
Posted on : Jul 25
-
Posted on : Jul 07
-
Posted on : Apr 07
-
Posted on : Mar 19
Optimized my.cnf configuration for MySQL 8 (on cPanel/WHM servers)
Tags
- layer 7
- tweak
- kill
- process
- sql
- Knowledge
- vpn
- seo vpn
- wireguard
- webmail
- ddos mitigation
- attack
- ddos
- DMARC
- server load
- Development
- nginx
- php-fpm
- cheap vpn
- Hosting Security
- xampp
- Plesk
- cpulimit
- VPS Hosting
- smtp
- smtp relay
- exim
- Comparison
- cpu
- WHM
- mariadb
- encryption
- sysstat
- optimize
- Link Building
- apache
- centos
- Small Business
- VPS
- Error
- SSD Hosting
- Networking
- optimization
- DNS
- mysql
- ubuntu
- Linux