Got this error when adding new websites to an Nginx host:
[warn] : could not build optimal server_names_hash, you should increase either
server_names_hash_max_size: 512 or server_names_hash_bucket_size: 64;
ignoring server_names_hash_bucket_size
Basically, that warning means nginx has too many / too-long server_name entries now, and the internal hash table it uses to match hostnames is too small. The default config is to keep the hash table quite small.
You don’t need to change any of your site configs — you need to adjust global nginx hash settings.
On Ubuntu, the config file is /etc/nginx/nginx.conf
You should increase one or both of these directives:
• server_names_hash_max_size
• server_names_hash_bucket_size
They go in the http {} block, not inside a server {} block.
The following example settings will double the default values and likely allow you to grow for a while. Increase as needed...
http {
server_names_hash_max_size 1024;
server_names_hash_bucket_size 128;
...
}