springBoot uploads files and reports 413 Request Entity Too Large

When I use the springBoot project to upload a 2M Excel file, "413 Request Entity Too Large" is reported. At first I thought it was a problem with the springBoot configuration file, so I took a look and found that the configuration file has been configured and cannot exceed 10M.

 Obviously it is not a problem caused by springBoot. I thought that our project uses nginx for load balancing, so could it be a limitation caused by nginx? So I entered the nginx directory of the test environment, checked the nginx.conf configuration file, and found that it There is no configurable upload file size limit,

Then the problem is obvious. The default upload file size of nginx is 1M, which must be exceeded, so I added a sentence of configuration under http:

 client_max_body_size 10M;

 Limit the file size to 10M as configured. And run the following command in the file where nginx is located to restart the configuration:

../sbin/nginx -s reload

 Upload the file again and receive it successfully

Guess you like

Origin blog.csdn.net/chenmaolin928/article/details/130425073