client_header_buffer_size

Sets the size of the buffer used for reading client request headers.

Syntaxclient_header_buffer_size size;
Default1k;
Contexthttp, server
Arguments1

Description

The client_header_buffer_size directive in NGINX allows you to specify the size of the buffer allocated for reading the headers of incoming client requests. This is crucial for managing how much header data NGINX can handle at once before it starts to store additional header data in other buffers. When a client sends HTTP headers, they are processed by NGINX, and if the combined header size exceeds the specified buffer size, NGINX will use larger buffers to accommodate the data. This can help prevent issues with large headers, such as those encountered with some authentication and cookie configurations.

This directive is particularly important in scenarios where you might expect larger headers due to increased cookie sizes or other custom headers. If the buffer is set too low, it can lead to errors such as 413 Request Entity Too Large or increased latency in processing requests with large headers. Administrators should be cautious in setting this value, as increasing it too much can lead to unnecessary memory consumption, particularly under heavy loads or while handling numerous concurrent connections. The directive is defined at the http and server contexts, making it flexible for use in global or server-specific configurations.

Config Example

server {
    listen 80;
    server_name example.com;

    client_header_buffer_size 2k;
}

Setting the buffer size too high might lead to excessive memory usage for high traffic sites.

Changes to this directive require a restart of NGINX to take effect.

← Back to all directives