Modify the size limit of files uploaded by nginx

Source: Internet
Author: User

When nginx is used as the reverse proxy, a strange problem occurs. You can submit small files. If a large file is used, an internal error of 500 will be reported. What causes this?

Check the wiki and we can see that there are three configurations related to the size of the uploaded file.

Client_body_buffer_size: configure the cache size of the Request body. If not,

Client_body_temp_path sets the path for storing temporary files. The uploaded Request body is written to a temporary file only when it exceeds the cache size.

Set client_max_body_size to the maximum value of the uploaded file.


The cause of the problem is

1. The file size exceeds client_body_buffer_size.

2. The temporary file path of client_body_temp_path has no write permission.

The Error 500 is returned for the preceding two reasons.


If the size of the uploaded file exceeds client_max_body_size, the error 413 entity too large is reported.


The reason is known, and the correction is simple.

1. client_body_buffer_size should be set as large as possible. This is based on the speed. If the size of the file to be uploaded is too small, it will be too slow to write to the disk.

2. The client_body_temp_path must have the write permission. This is an obvious error. Just correct it.

3. client_max_body_size sets the maximum value of the uploaded file. This is based on security considerations. We believe that normal users will not or will not upload too many files.

It can be set to client_max_body_size 100 m, or set this value according to your own business.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.