client_body_timeout

The `client_body_timeout` directive sets a time limit for reading the client request body.

Syntaxclient_body_timeout time;
Default60s
Contexthttp, server, location
Arguments1

Description

The client_body_timeout directive specifies a timeout value that determines how long the server will wait for the client to send the full body of a request. This includes POST and PUT requests where the body of the request may be substantial. If the client does not send the complete body within the specified time frame, NGINX will close the connection and return a 408 Request Timeout error. This timeout helps in managing server resources effectively by preventing hanging connections.

This directive can be used in various contexts: http, server, and location, making it versatile for configuring different scopes of request handling. It takes a single argument, which is the duration of the timeout value, typically specified in seconds or the format understood by ngx_time_t, such as '30s', '1m', etc. Setting the timeout appropriately is crucial to prevent slow clients from monopolizing server resources, especially in high traffic scenarios. It is important to note that configurations set at a more specific context (like location) will override those set at a higher context (like http).

Config Example

http {
    client_body_timeout 30s;
    server {
        location /upload {
            client_body_timeout 5s;
        }
    }
}

Setting the timeout too low may lead to unintended 408 Request Timeout errors for clients with slower connections or those sending large amounts of data.

If not defined, the default value is 60 seconds which might not be ideal for all applications, especially if handling large uploads.

← Back to all directives