Nginx could not the server_names_hash error resolution

  • 2020-05-07 20:52:43
  • OfStack

To nginx configuration, after a long domain names through/usr local/nginx/sbin/ngnix - t check under 1 errors in the configuration file:

could not build the server_names_hash, you should increase server_names_hash_bucket_size: 32

The solution is to add the following configuration to the http section of the nginx configuration file:
server_names_hash_bucket_size 64;

If it already exists, you need to increase the following value, note: the value is a multiple of 32.
The following is the nginx official documentation:
 If you have a large number of names defined, or if you have a very long name defined, you may need to have a http Used in the configuration block server_names_hash_max_size and server_names_hash_bucket_size The instructions are adjusted. server_names_hash_bucket_size The default value may be 32 , or the 64 Or some other value, depending CPU The length of the cache row. If this value is zero 32 , then define" too.long.server.name.example.org "As the virtual host name will fail, and nginx Displays the following error message: 
could not build the server_names_hash,
you should increase server_names_hash_bucket_size: 32
 When this happens, you need to expand the value of the instruction 1 Times: 
http {
    server_names_hash_bucket_size  64;
    ...
 If you define a lot of names, you get another 1 Error: 
could not build the server_names_hash,
you should increase either server_names_hash_max_size: 512
or server_names_hash_bucket_size: 32
 Then you should try setting it first server_names_hash_max_size Is approximately equal to the total number of names in the name list. If the problem is not resolved, or the server starts very slowly, try to improve server_names_hash_bucket_size The value of the. 


Related articles: