Getting 413 Request Entity Too Large on Plesk hosted website
Once in a while, I have some issues on Plesk when nginx is enabled. Every post request returns a 413 Request Entity Too Large
response, preventing the web applications to work properly.
What is happening
For every POST request made to the web application, a 413 Request Entity Too Large
response is returned, even when the request body is empty or very low:
413 Request Entity Too Large
nginx
In the domain Apache & nginx Settings, the Maximum allowed HTTP request body size is set to a high value (much higher than the request size) :
Requests and errors are not showing up in the domain logs :
Why it is happening
I couldn't figure it clearly, but it is clearly lin to the nginx configuration. Since the requests don't appear in the domain log, I supposed that a global server configuration is overriding the domain settings, preventing the request to even reach the domain.
How to solve it
I could get a workaround by adding a global client_max_body_size
value in a global nginx setting file.
However, this will override any local per domain settings made in Plesk in the Apache & nginx Settings section.
Step 1: edit the nginx default file
Connect by SSH to the server and enter the following command to edit the nginx default file:
nano /etc/nginx/nginx.conf
Add the following line to the http section :
http {
[...]
client_max_body_size 512m;
}
This will allow a post size of 512MB server-wide.
Step 2: restart the server
systemctl reload nginx