`

JoyentJoyent

Knowledge Base

12.18. Disabling mod_security

If you’re seeing a lot of “Error 412: precondition failed” errors, it’s most likely the result of something triggering a rule in mod_security. TextDrive uses mod_security to block comment and referrer spam, but sometimes it get’s triggered by mistake. This can happen if something on your site (like a URL) matches a common pattern (like ”-poker”, ”-pictures”, or ”-sex”).

A quick way to resolve this is to put the following in a .htaccess file in your public or public_html directory:

SecFilterEngine Off

This will disable mod_security for your domain.

More about what .htaccess files are an how to use them can be found here and here.

Note: If you’re proxying your domain to Lighttpd, this won’t work however. You’ll need to open a support request and we will disable mod_security for you in the main Apache configuration file.

Be aware that once you disable mod_security you are no longer protected from referrer and comment spam.

Once mod_security is disabled you can troubleshoot this by looking through your logs to determine what rules are being triggered. Once you know what rules are being triggered you can selectively turn them off to get everything back up and running again.

As an example, if a you find a URL on your site is creating the following error:

The precondition on the request for the URL /path/poker.php evaluated to false

you would add the following to an .htaccess file:


SecFilterEngine On
SecFilterSelective "REQUEST_URI" "/path/poker.php" "allow,nolog"

Sometimes the 412 error can also occur when posting something to your site via a form, like when the content contains a specific word like “poker”.

In this case you would add the following to an .htaccess file:


SecFilterEngine On
SecFilterSelective "POST_PAYLOAD" "poker" "allow,nolog"

If you’re still having issues with mod_security, file a ticket and we’ll help you troubleshoot the issue.