413 Request Entity Too Large error occurs in Nginx. This error usually occurs when uploading files. Open the nginx main configuration file nginx.conf, find the http{} section, and add
The solution is
Open nginx main configuration file nginx.conf, usually at /usr/local/nginx/conf/nginx.conf, find the http{} section, modify or add
client_max_body_size 2m;
Copy after login
Then restart nginx,
sudo /etc/init.d/nginxd reload
Copy after login
That’s it.
If running in php, the size client_max_body_size should be similar to or slightly larger than the maximum value of the following value in php.ini, so that errors will not occur due to inconsistent submitted data sizes.
post_max_size = 2M
upload_max_filesize = 2M
Copy after login
Restart NGINX
kill -HUP `cat /usr/local/nginx/nginx.pid `
Copy after login
In order to prevent timeouts when uploading large files, you need to increase the value of max_execution_time appropriately.
The above introduces the solution to the 413 Request Entity Too Large error in Nginx, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.