[Solved] Nginx Request 500 Error: CreateFile() “/temp/client_body_temp/0000000013” failed (5: Access is denied)

In the past few days, when a front-end colleague was processing upload requests, nginx returned a 500 error. There was no additional error information, and the back-end did not receive the request. Look at his local nginx log error:

[crit] 28700#21636: *1389 CreateFile() "\nginx-clean/temp/client_body_temp/0000000010" failed (5: Access is denied)<br> Changing **/temp/client_body _temp folder to the group of users executing Nginx and it will be solved

 

nginx has several upload-related parameter descriptions:
client_max_body_size
client_max_body_size defaults to 1M, indicating the maximum allowable size of the client request server, which is specified in the “Content-Length” request header. If the requested body data is larger than client_max_body_size, the HTTP protocol will report the error 413 Request Entity Too Large.

client_body_buffer_size
Nginx allocates the Buffer size of the requested data. If the requested data is smaller than client_body_buffer_size, it directly stores the data in memory first. If the requested value is greater than client_body_buffer_size and less than client_max_body_size, the data will be stored in a temporary file first

client_body_temp_path 

Specify the temporary storage path. By default, the path value is
the client_body_temp address configured in /tmp/client_body_temp, and the user group of the executing Nginx must have read and write permissions. Otherwise, when the transmitted data is larger than client_body_buffer_size, an error will be reported if it fails to write to the temporary file

Syntax: client_body_temp_path dir-path[level1[level2[level3]]
If the package body size is larger than client_body_buffer_size, it will be named with an increasing integer and stored in the directory specified by client_body_temp_path. The level1, level2, and level3 that follow are used to prevent the number of files in a directory from being too large and thus causing performance degradation,<br>hence the use of the level parameter, so that it can follow the temporary

 

client_body_in_file_only on|clean|off;

When the value is not off, the HTTP packet body in the user request will always be stored in the disk file, even if it has only 0 bytes, it will be stored as a file.

When the request ends, if the configuration is on, the file will not be deleted (this configuration is generally used for debugging and locating problems), but if the configuration is clean, the file will be deleted.

Summarize:

If the transmitted data is larger than client_max_body_size, the transmission must be unsuccessful, and the HTTP protocol will report an error 413 Request Entity Too Large
is smaller than client_body_buffer_size, which is directly stored in memory efficiently.
If it is larger than client_body_buffer_size and smaller than client_max_body_size, temporary files will be stored, and temporary files must have permissions.
If the pursuit of efficiency, set client_max_body_size and client_body_buffer_size the same value, so that temporary files will not be stored, stored directly in memory.

Read More:

Leave a Reply

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