nginx upload file size error 500 solution

  • 2020-05-13 04:34:12
  • OfStack

nginx upload file size error 500 solution

Using nginx as reverse proxy, a weird problem occurred. Small files can be submitted, while large files will report 500 internal errors. What causes this?

Check wiki to see that there are three configurations related to the size of the uploaded file

client_body_buffer_size configuration request body cache size, if not, client_body_temp_path sets the temporary file storage path. Only when the body of the uploaded request exceeds the size of the cache will it be written to the temporary file client_max_body_size sets the maximum value of the uploaded file

So here's what caused the problem

1. The file size exceeds client_body_buffer_size

2.client_body_temp_path's temporary file path has no write permissions

The return 500 error was caused by the above two reasons.

If the file size is larger than client_max_body_size, an error of 413 entity too large is reported.

Once you know why, it's easy to fix it.

1. Try to set client_body_buffer_size as large as possible. This is based on the consideration of speed.

2. The client_body_temp_path path must have writable permissions, this is an obvious error. Correct it

3.client_max_body_size sets the maximum value of the uploaded file. This is for the sake of security.

It can be set to client_max_body_size 100m; Or set the value for your business.

The above is the solution of nginx file upload error, if you have any questions, please leave a message or to the community of this site to discuss the common progress of everyone, thank you for reading, hope to help you, thank you for your support of this site!


Related articles: