http2_max_header_size

The http2_max_header_size directive sets a limit on the maximum size of headers in HTTP/2 requests and responses.

Syntaxhttp2_max_header_size size;
Defaultnone
Contexthttp, server
Arguments1

Description

The 'http2_max_header_size' directive is used to control the maximum size of HTTP/2 headers that the NGINX server is willing to process. This directive helps in mitigating potential denial of service attacks by preventing excessively large headers from consuming excessive server resources. The value for this directive is specified in bytes, and setting it appropriately is crucial for ensuring that the server can handle typical requests efficiently while still maintaining performance and security. If a header exceeds this limit, NGINX will return an error to the client, thus preventing the server from being overwhelmed by large header sizes.

The directive can be configured at the 'http' and 'server' contexts, allowing fine-tuning at different levels of the server configuration. It accepts a single argument, which denotes the maximum allowed size for headers. Keep in mind that very small values may lead to legitimate requests being rejected, while very large values may leave the server vulnerable to performance issues or exploitation via malformed requests.

Config Example

http {
    http2_max_header_size 4096;
}

server {
    http2_max_header_size 8192;
}

Setting the directive to a value too low can result in legitimate requests being denied, leading to usability issues.

Remember to test configurations after changes to ensure that important headers are not inadvertently blocked.

← Back to all directives