Adjusting server_names_hash_bucket_size before nginx throws an error

Maxim Dounin mdounin at mdounin.ru
Thu Jan 12 15:38:28 UTC 2017


Hello!

On Thu, Jan 12, 2017 at 03:12:30PM +0300, Vladimir Kozyrev wrote:

> My issue is that I add server {} and upstream {} directives dynamically to
> /etc/nginx/conf.d/dynamic_vhost.conf.
> Once the file grew, nginx stopped working and I increased hash_bucket_size
> parameter to make it work again.
> Is there a way to calculate what value should I set to hash_bucket_size
> parameter for a given number of server {} and upstream {} directives? At
> some point, the file will grow big enough to stop nginx from working once
> again.
> Any advice on how can I prevent that from happening will be appreciated.

The value of server_names_hash_bucket_size limits the maximum 
length of a server_name used.  If you use long server names, set 
it to the maximum name length expected (plus some additional space 
for two pointers).

Everything else is not fatal when constructing hashes since nginx 
1.5.13.  If nginx fails to build an optimal hash with bucket_size 
and max_size configured, it simply ignores bucket_size and logs an 
appropriate warning (non-fatal).

Some additional information about configuring hashes can be found 
at http://nginx.org/en/docs/hash.html.

-- 
Maxim Dounin
http://nginx.org/


More information about the nginx mailing list