Symptoms
-
When uploading a file in PHP, one of the following errors will appear in the Apache logs:
CONFIG_TEXT: ModSecurity: Request body (Content-Length) is larger than
the configured limit (134217728).CONFIG_TEXT: ModSecurity: Output filter: Content-Length (529160) over the limit (524288).
-
WordPress will also receive the 403 response in the website's PHP domain access_log file:
CONFIG_TEXT: POST /wp-admin/async-upload.php HTTP/1.1" 403
-
Another error that could appear on the website page is:
CONFIG_TEXT: Request Entity Too Large
The requested resource does not allow request data with GET requests,
or the amount of data provided in the request exceeds the capacity limit.
Additionally, a 413 Request Entity Too Large error was encountered
while trying to use an ErrorDocument to handle the request.
Cause
cPanel installs Mod_Security via EasyApache by default to increase web security. Mod_security has a default setting to block large requests to prevent DoS attacks and other security risks.
Two of the most common causes are the following settings:
- SecRequestBodyLimit
- SecResponseBodyLimit
Note: More details can be found in the Documentation pages:
Mod_Security rules reference page for version 2.x
Resolution
Increase the SecRequestBodyLimit and/or SecResponseBodyLimit in the configuration file.
- How to log into server using SSH?
- Edit file
/etc/apache2/conf.d/modsec/modsec2.user.conf -
Set the limits for the following settings:
Set SecRequestBodyLimit, SecResponseBodyLimit, and/or SecRequestBodyNoFilesLimit to a value higher than the default limits, for example:
Note: This file is usually empty by default. You will need to edit the existing value or add a new line to set the custom value.
CONFIG_TEXT: SecRequestBodyLimit 546870912
SecResponseBodyLimit 5242880
SecRequestBodyNoFilesLimit 10485760 -
Save the file, then restart Apache.
# /scripts/restartsrv_httpd
After restarting Apache, refresh the webpage and then try the upload once more.
Additional Resources
If you need to adjust the php.ini upload settings, please review the related article below to assist with this task.
Comments
0 comments
Article is closed for comments.