Attempting file uploads on the websites don't complete, or they fail. The Nginx log will show the below similar errors:
Note: The Nginx error log can be located at path: "
*494756 client intended to send too large body: 1778270 bytes
Nginx has a limit on the body size by default. If the limit is exceeded, an error will occur log file, and most commonly, it will be observed on the website as a failure to upload the files.
The Nginx configuration will need to be modified to allow larger upload sizes. The desired upload size will need to be set with the option: "
client_max_body_size" in the Nginx configuration.
Note: This also assumes that the PHP INI configurations have already been adjusted to include the higher upload/post limits.
We have recently added the client_max_body_size configuration to the configuration template used to generate the main NGINX configuration. Because of this, it is not possible to add or edit the client_max_body_size configuration by manually altering a regular configuration file. Instead, you'll need to use the following steps to modify the settings.json configuration for NGINX.
- Login to the server via SSH or Terminal as the root user
- Please run the following command, but be sure to update it with your desired value for the client_max_body_size setting. The setting included in this example is 500m.
sed -i.$(date +.%Y-%b-%d-%H-%M-%S) 's/}$/,"client_max_body_size": "500m"}/' /etc/nginx/ea-nginx/settings.jsonNOTE: The above command will create a backup of the original file in the same directory as the original file if you need to restore the original file.
- Rebuild the configuration to include your new chosen setting value:
/usr/local/cpanel/scripts/ea-nginx config --global
- Verify that the change worked by checking the value in the configuration file
grep client_max_body_size /etc/nginx/conf.d/ea-nginx.conf
Workaround Alternative: ( CloudLinux Servers )
If the server is CloudLinux, please follow the below steps as CloudLinux servers are generally a few weeks behind cPanel's EasyApache update servers.
The below changes will need to be made in the SSH/Terminal via editing files with a text editor for Linux like vi, vim, or nano. It is strongly recommended to make these changes with an administrator's assistance to prevent configuration files. Making the wrong change could cause the service to go offline.
1. Edit the "
http" block: ( Will apply settings globally )
Create a new file in the conf.d directory for Nginx.
2. Edit the new file: "
/etc/nginx/conf.d/maxuploadsize.conf" to add below syntax to set 500m limit:
3. Restart Nginx and FPM.
For more information on customizing Nginx settings, it is best to review the official documentation page.