Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Servers, nginx and Docker

'Not Acceptable' page generated by Mod_Security

ErrorNot Acceptable!

Short answer

ModSecurity matched a rule against your request and denied it, so Apache never reached PHP. Find the rule ID in the audit or error log, then remove that one rule for that one location with SecRuleRemoveById, or test with DetectionOnly. Do not switch the whole engine off.

  • Applies to ModSecurity 2.x on Apache
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Find the ModSecurity entry for the blocked request. It names the rule id that matched.

    sudo grep -i "modsecurity" /var/log/apache2/error.log | tail -n 20
  2. 2Match what you see, then jump to its fix

    1. 1The log line has an id and a message for the rule, and the blocked request is a normal form post or URLA single rule matched your legitimate requestFix
    2. 2Several ids appear in the log for one requestYou are not sure which rule is responsibleFix

What does the error look like?

  • Not Acceptable!
  • An appropriate representation of the requested resource could not be found on this server. This error was generated by Mod_Security.

Cause 1 of 2

A single rule matched your legitimate request

1Check

Note the id from the log. ModSecurity rules need a numeric id, and the audit log (SecAuditLog) records the full request.

sudo grep -ri "SecAuditLog" /etc/modsecurity /etc/apache2 2>/dev/null

2Fix

Remove that rule for the context that needs it, in a location or virtual host block rather than globally. SecRuleRemoveById takes rule ids.

<LocationMatch "^/admin/save\.php$">
    SecRuleRemoveById 100001   # example id: use the id from your log
</LocationMatch>

3Verify

Test the config, reload Apache and repeat the request.

sudo apachectl configtest && sudo systemctl reload apache2

Confirmed by github.com

Did this fix it?

Cause 2 of 2

You are not sure which rule is responsible

1Check

SecRuleEngine can run in DetectionOnly, where rules are processed and logged but disruptive actions such as deny are not executed.

grep -rn "SecRuleEngine" /etc/modsecurity /etc/apache2 2>/dev/null

2Fix

Switch to DetectionOnly for a short test on a non-production host, make the request, read which ids log, then remove only those rules and switch back to On.

SecRuleEngine DetectionOnly

3Verify

The request passes while the log still lists the matching ids.

sudo grep -i modsecurity /var/log/apache2/error.log | tail -n 20

Confirmed by github.com

Did this fix it?

How do I stop it coming back?

  • Remove rules by id and by location, never the whole engine.
  • Keep a comment next to each SecRuleRemoveById saying what request it unblocks.
  • Re-test after every ModSecurity rule set update, since ids can change.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Related fixes

Servers

dnf cannot install MySQL on Amazon Linux 2023

dnf cannot find a mysql-server package on Amazon Linux 2023

Amazon Linux 2023 documents MariaDB, not MySQL, as its database server, with packages named mariadb105 and mariadb105-server.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.