A busy cPanel server with ModSecurity in SecAuditEngine On mode and the full audit log enabled writes hundreds of megabytes a day of request and response data. Most of it is noise — legitimate requests that match no rule. The default cPanel value is RelevantOnly for exactly this reason; the trap is the operator who flipped it to On while debugging a single issue and never flipped it back.
What’s happening
ModSecurity has three audit modes: Off (no log), On (log every request), and RelevantOnly (log only requests that triggered a rule or returned an error). RelevantOnly is what you want in steady state. SecAuditLogParts controls how much of each transaction is logged — request headers, request body, response headers, response body, and a few internal parts. The body parts are by far the biggest contributors to disk usage.
How to verify
Confirm the current ModSecurity audit config:
grep -r "SecAuditEngine\|SecAuditLogParts\|SecAuditLog " /etc/apache2/conf.d/ /etc/cpanel/ea4/
whmapi1 modsec_get_settings
du -sh /etc/apache2/logs/modsec_audit.log /usr/local/apache/logs/modsec_audit.log 2>/dev/null
wc -l /etc/apache2/logs/modsec_audit.log 2>/dev/null
If SecAuditEngine On is set anywhere (not RelevantOnly), the log is recording every request.
The fix
- WHM > ModSecurity Tools > Rules List > scroll to Audit Engine. Set to
RelevantOnly. Save. - Set
SecAuditLogPartsto a sensible subset. The defaultABIJDEFHZincludes response bodies (E). On a busy host, dropE—ABIJDFHZ. You lose response body inspection but keep request data and headers, which is what 90% of investigations need. - Switch to concurrent logging if not already.
SecAuditLogType Concurrentwrites each transaction to its own file underSecAuditLogStorageDir, which makes log rotation trivial and avoids the lock contention ofSerial. cPanel defaults toSerial; concurrent is the better choice on a busy host. - Set up a directory cleanup. With concurrent logging, files accumulate. A daily
find /var/log/modsec_audit -type f -mtime +14 -deletekeeps disk usage bounded. apachectl -t && apachectl graceful. Watch the log directory grow rate:watch -n 60 'du -sh /var/log/modsec_audit'. It should be substantially lower than before.- If you need to debug a specific request — say a customer reports a block — temporarily enable
SecAuditEngine Onscoped to that vhost via the Include Editor, capture the audit data, then disable. Do not leave it on globally.
For environments where ModSecurity audit data feeds compliance retention, Stack Harbor configures the log shape against the retention requirement under cPanel/WHM management.