proxy_headers_hash_max_size
Defines the maximum size of the hash table for storing proxy headers.
Description
The proxy_headers_hash_max_size directive is used in the NGINX HTTP server to set the maximum size of the hash table that stores the keys of HTTP headers when using the proxy_set_header directive. This is particularly relevant when NGINX operates as a reverse proxy, as it facilitates the mapping of the incoming headers to the corresponding backend server headers.
The parameter for this directive is a number that determines how many hash entries can be created. In scenarios where a large number of different headers may be set or modified, increasing this value can help prevent hash table collisions and improve performance. It's essential to strike a balance—setting this value too high can lead to increased memory consumption, while a value set too low may lead to hashing conflicts, resulting in potential issues in header retrieval.
The directive can be used in the http, server, and location contexts, allowing for flexible configuration at different levels of the NGINX hierarchy. When properly configured, it enhances the ability of NGINX to manage proxy headers efficiently, especially under high-load conditions with numerous distinct header types.
Config Example
proxy_headers_hash_max_size 1024;
Setting the proxy_headers_hash_max_size too low may lead to performance degradation due to hash collisions.
Increasing the size may lead to higher memory utilization, so consider the server's available resources before scaling.