Solution to "413 Request Entity Too Large" in Nginx

Open the nginx configuration file nginx.conf, the path is usually: /etc/nginx/nginx.conf. Add client_max_body_size 20m in the http{} section;

20m is the maximum upload size allowed. Save and restart nginx to solve the problem.

Solution to the 413 Request Entity Too Large problem

When uploading a picture (size 1.9M) using PHP, an nginx: 413 Request Entity Too Large error occurs.

According to experience,The size of uploaded files is limited, but the default file upload in PHP is 2M, so there should be no problem.

Open php.ini, change upload_max_filesize and post_max_size to 20M, and restart.

Upload again, the problem still exists, so the problem with PHP can be ruled out.

The default upload file size of nginx is 1M, which can be modified in the nginx settings.

The solution is as follows:

1. Open , the path is generally: /etc/nginx/nginx.conf.

2. Add in the http{} section:

client_max_body_size 20m;

The maximum upload size allowed is 20m.

3. Save and restart nginx to solve the problem.

score

Leave a Reply

Your email address will not be published. Required fields are marked *