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:
- Nginx Container Error: nginx: [emerg] mkdir() “/var/cache/nginx/client_temp“ failed (13: Permission denied)
- [Solved] Ora-01652 Error: unable to extend temp section through 128 (in table space temp)
- How to Solve Nginx 413 Error (request entity too large)
- Fetch Error: Failed to execute ‘fetch’ on ‘Window’: Request with GET/HEAD method cannot have body
- [Solved] Axios Error: Request body larger than maxBodyLength limit
- [Solved] Chrome Error: The request client is not a secure context
- [Solved] Error: ER_ACCESS_DENIED_ERROR: Access denied for user ‘root’@‘localhost’ (using password: YES)
- [Solved] Nginx Error: 400 Request Header Or Cookie Too Large
- [Solved] Browser Access Error: Request Header or Cookie too large
- [Solved] Windows Nginx Startup Error: bind() to 0.0.0.0:80 failed (10013: An attempt was made to access a socket
- [Solved] win32diskimager Error: An error occured when attempting to XXX, Error 5: Access is Denied
- SourceTree Git Error: remote: HTTP Basic: Access denied fatal: Authentication failed
- [Solved] Docker Start nginx error: driver failed programming external connectivity on endpoint nginx
- Springcloud configuration center client 3355 startup Error: error on get request for“ http://localhost:8761/eureka/apps/ “: Connection
- [Solved] Playbook Start Nginx Error: Unable to start service nginx: Job for nginx.service fd with error code
- [Solved] Error: failed to create deliver client: orderer client failed to connect to orderer.example.com:7050
- [Solved] C# OPC Client Access OPC Server Error: SunFull.X2OPC.1
- [Solved] failed (13: Permission denied) while reading upstream
- Current request is not a multipart request [How to Solve]
- [Solved] Flink jdbc Error: Access Denied for user ‘root‘@‘10.0.0.x‘ (using password: YES)