Security (Imunify360, ModSecurity)

Comprehensive Guide to ModSecurity: Logs, Configuration, and Important Limits

By the Domain India teamPublished 10 min read
Knowledge base article
Contents (9 sections)

ModSecurity is the web application firewall (WAF) that sits inside the web server and checks every request before your website sees it. It stops a lot of automated attacks, and now and then it also blocks something legitimate. This guide explains how it works, what it does on Domain India shared hosting, how to report a false positive, and how to configure its logs and limits on your own VPS.

Key takeaways

On Domain India shared hosting, ModSecurity is managed by us for the whole server: it is always on, customers cannot switch it off or edit its rules, and on our cPanel servers it uses Imunify360's full ruleset. If it blocks something legitimate, open a ticket with the exact URL, the time and your public IP address so we can find the rule in the logs. On a VPS you control ModSecurity yourself; the logs, directives and limits below apply there.

1. What ModSecurity does

ModSecurity is an open-source WAF engine. It runs as a module in Apache (version 2, mod_security2) or as a library with a connector for nginx (version 3, libmodsecurity). Since 2024 the project has been maintained under OWASP.

On its own the engine does nothing. It needs a ruleset: a list of patterns that describe attacks such as SQL injection, cross-site scripting, remote file inclusion and path traversal. The best-known free ruleset is the OWASP Core Rule Set (CRS). Commercial rulesets, such as the one that ships with Imunify360, are also common on hosting servers.

ModSecurity checks a request in five phases:

PhaseWhat it inspectsTypical use
1Request headersBlock bad bots, bad methods, known attack URLs
2Request body (form fields, uploads, JSON)Most attack rules run here
3Response headersRarely used
4Response bodyDetect data leaks (costly, often off)
5LoggingDecide what goes into the audit log

When a rule matches, ModSecurity can log the request, block it (usually with a 403), or add to an anomaly score that blocks the request only when the total passes a threshold. The CRS works this way.

2. ModSecurity on Domain India shared hosting

We checked our shared servers directly (measured on our servers, 20 and 23 September 2026):

  • The cPanel servers run Apache with the security2_module (ModSecurity 2) loaded.
  • The ruleset is Imunify360's full Apache ruleset, set to FULL, with application-specific rules for common CMSs switched on.
  • It is configured server-wide. Every account on a server gets the same protection, whatever plan it is on.
  • The ModSecurity switch is disabled in the cPanel interface for customer accounts, so you cannot turn it off per domain or edit rules yourself.

This is deliberate: on a shared server, one site with its firewall off is an easy way in for attackers.

ModSecurity lines in .htaccess do not work

Directives such as SecRuleEngine Off or SecRuleRemoveById are not allowed in .htaccess with ModSecurity 2. Adding them gives your site a 500 error. Ask support instead.

3. How to recognise a ModSecurity block

A WAF block has a typical pattern: the site works, but one action fails.

  • You save a long post or a page-builder layout and get 403 Forbidden.
  • A contact form or checkout fails only when the message contains code, SQL-like words or unusual characters.
  • An upload or an import fails with a 403 while normal pages load fine.
  • An admin plugin or an API call to your own site is refused.

If the whole site is down, or it times out rather than showing a 403, it is not a WAF rule. Look at Understanding and resolving HTTP error 403 Forbidden, which covers permissions, .htaccess rules and IP blocks by the server firewall.

4. Report a false positive on shared hosting

A false positive is a legitimate request that a rule mistook for an attack. We can find the exact rule in the server logs, but only if you tell us which request to look for.

  1. Repeat the action once.
    Note the exact time, including the date, as close to the minute as you can.
  2. Copy the full URL
    from the address bar, and write down what you did (for example "clicked Update on the About page").
  3. Find your public IP address.
    Search "what is my IP" in any search engine from the same device and connection.
  4. Open a ticket
    at /client/support/new when logged in, or at /support/ticket, with those three details.
  5. Wait for our reply before changing things.
    We check the log entry and the rule that fired, and decide whether a precise exception is safe for your site.

Don't disable security plugins or loosen file permissions to get round a block. It rarely helps and weakens the site.

5. Where ModSecurity logs live (VPS and your own servers)

On a server you manage, ModSecurity writes to two places.

LogTypical pathWhat it contains
Web server error log/var/log/apache2/error.log (Debian/Ubuntu), /var/log/httpd/error_log (AlmaLinux/RHEL), /var/log/nginx/error.logOne line per match: rule ID, message, URI, client IP
Audit log/var/log/apache2/modsec_audit.log or /var/log/httpd/modsec_audit.logFull request and response details for matched transactions

Paths differ by distribution and control panel, so check the SecAuditLog line in your configuration.

To find recent blocks and the rules behind them:

bash
# Recent ModSecurity matches in the Apache error log (Debian/Ubuntu)
sudo grep -i "ModSecurity" /var/log/apache2/error.log | tail -n 20

# Only the rule IDs, most frequent first
sudo grep -o 'id "[0-9]*"' /var/log/apache2/error.log | sort | uniq -c | sort -rn | head

# Everything logged for one request, using its unique_id
sudo grep -A 40 "UNIQUE_ID_HERE" /var/log/apache2/modsec_audit.log

Each audit entry is split into lettered parts: A (time, IPs, unique ID), B (request headers), C (request body), F (response headers), H (the rules that matched and the action taken) and Z (end of entry). SecAuditLogParts controls which parts are written. The H part tells you which rule fired.

Rotate the audit log with logrotate: it grows quickly, and request bodies can contain personal data.

6. Key directives and their default limits

These come from the modsecurity.conf-recommended file that ships with ModSecurity 2. Your distribution may set different values, so read the actual file before changing anything.

DirectiveRecommended defaultWhat it controls
SecRuleEngineDetectionOnlyOn blocks, DetectionOnly only logs, Off disables
SecRequestBodyLimit13107200 (12.5 MB)Largest request body, including uploads
SecRequestBodyNoFilesLimit131072 (128 KB)Largest request body not counting file uploads
SecRequestBodyLimitActionRejectWhat happens when a body is too big
SecResponseBodyLimit524288 (512 KB)How much of a response is inspected
SecPcreMatchLimit1000Limits regex work, to prevent CPU exhaustion

Note that a new ModSecurity install on Debian or Ubuntu starts in DetectionOnly. It logs but blocks nothing until you set SecRuleEngine On.

A common real problem is a large upload or a big JSON form being refused. Raise the matching limit, then reload the web server:

apache
# Allow uploads up to 64 MB and form data up to 1 MB
SecRequestBodyLimit 67108864
SecRequestBodyNoFilesLimit 1048576
bash
sudo apachectl configtest && sudo systemctl reload apache2   # Debian/Ubuntu
sudo apachectl configtest && sudo systemctl reload httpd     # AlmaLinux/RHEL

PHP has its own limits (upload_max_filesize, post_max_size) and so does nginx (client_max_body_size). All of them must allow the size you need.

7. Tuning false positives on your own server

Never switch the whole engine off to fix one false positive. Remove the smallest thing that solves the problem, and put your exclusions in a file that loads after the ruleset.

apache
# 1. Turn off one rule for one URL only
<LocationMatch "^/wp-admin/post\.php">
    SecRuleRemoveById 941100
</LocationMatch>

# 2. Keep the rule, but stop it checking one field
SecRuleUpdateTargetById 942100 "!ARGS:content"

# 3. Remove a rule everywhere (last resort)
SecRuleRemoveById 941100

With the OWASP CRS, also consider the paranoia level (1 is the default and gives the fewest false positives) and the anomaly threshold. Test changes with the engine in DetectionOnly for a few days, read the logs, then switch to On.

8. Installing ModSecurity on a VPS

On current Linux distributions, ModSecurity 2 for Apache and the OWASP CRS come from the normal package repositories.

bash
# Debian / Ubuntu
sudo apt install libapache2-mod-security2 modsecurity-crs
sudo cp /etc/modsecurity/modsecurity.conf-recommended /etc/modsecurity/modsecurity.conf
sudo a2enmod security2 && sudo systemctl restart apache2

# AlmaLinux / Rocky / RHEL
sudo dnf install mod_security mod_security_crs
sudo systemctl restart httpd

nginx needs ModSecurity 3 plus a connector module built for your exact nginx version, which is more work to maintain. If your VPS runs a control panel, use the panel's own WAF settings instead. Check the module is loaded with sudo apachectl -M | grep -i security.

9. Where Domain India fits

  • Shared hosting (cPanel, DirectAdmin or Webuzo) is for people who want the WAF managed for them. The ruleset, updates and exceptions are our job; you report false positives by ticket. Domain India list prices on 19 September 2026, excluding 18% GST: DirectAdmin Starter ₹100 a month and cPanel Starter ₹125 a month.
  • A VPS (VPS servers, from ₹552 a month) gives you root access, so you install, tune and log ModSecurity yourself using sections 5 to 8. Security on a VPS is your responsibility; see the VPS security checklist.

For the wider picture of what a WAF can and cannot stop, read Understanding and implementing a web application firewall.

Can I turn off ModSecurity for my domain on Domain India shared hosting?

No. On Domain India shared hosting, ModSecurity is managed server-wide and the per-domain switch is not available in the control panel. If a rule blocks something legitimate, open a ticket with the URL, the time and your public IP address so the rule can be found in the logs.

Which ModSecurity ruleset does Domain India use on shared hosting?

Our cPanel shared servers use Imunify360's full Apache ruleset, including its application-specific rules, configured the same way for every account on the server.

How do I know a 403 error came from ModSecurity?

A ModSecurity block usually affects one action, such as saving a post, submitting a form or uploading a file, while the rest of the site works. If the whole site shows 403 or times out, the cause is more likely permissions, an .htaccess rule or an IP block by the firewall.

Can I add SecRuleEngine Off to my .htaccess file?

No. ModSecurity 2 does not accept its directives in .htaccess, and adding them causes a 500 Internal Server Error. Configuration belongs in the server configuration, which on shared hosting is managed by the host.

What details should I send when reporting a false positive?

Send the full URL, the exact date and time the block happened, your public IP address, and a short description of what you did. With those, support can find the matching log entry and the rule ID.

Where is the ModSecurity audit log on a VPS?

It is set by the SecAuditLog directive. Common paths are /var/log/apache2/modsec_audit.log on Debian and Ubuntu and /var/log/httpd/modsec_audit.log on AlmaLinux and RHEL. Short summaries of each match also appear in the web server error log.

Ready to get started? Compare cPanel hosting with a managed firewall, choose a VPS if you want to run ModSecurity yourself, or open a ticket if a rule is blocking your site.

Blocked by a security rule?

Send us the URL, the time and your IP address, and we will check the rule that fired.

Open a ticket

Ready when you are

Get cPanel hosting from ₹125/mo + GST

See plans

Was this article helpful?

Your answer helps us decide what to improve next.

Still need help? Open a support ticket and our team will reply.

Prefer an app? Add this site to your home screen.Get the app