nginx: [emerg] could not build the server_names_hash, you should increase server_names_hash_bucket_size

后端 未结 4 1587
-上瘾入骨i
-上瘾入骨i 2020-12-23 09:05

I\'m in the process of setting up a new server. The http-Server of my choice is NGINX. I want to add the domain audi-freunde-einbeck.de as a virtual host. I alr

相关标签:
4条回答
  • 2020-12-23 09:17

    This sounds perhaps a bit random, but it might help an nginx newb like myself.
    I got this error when I left off a ; on the server_name line.

    had:

    server_name    www.mydomain.com  
    access_log     /var/log/nginx/www.mydomain.com; 
    

    fix:

    server_name    www.mydomain.com;  
    access_log     /var/log/nginx/www.mydomain.com; 
    

    All directives in nginx config files must end with a ;
    I often highlight ;s in my file before saving/uploading as a final check after editing.

    0 讨论(0)
  • 2020-12-23 09:17

    This is how I solved:

    cd /etc/nginx/
    
    sudo nano nginx.conf
    
    • --uncomment or add server_names_hash_bucket_size 64 --
    • --increase server_names_hash_bucket_size "164" --
    cd /etc/nginx/sites-available/
    
    sudo nginx -t
    
    
    • if all it's ok
    sudo service nginx restart
    
    0 讨论(0)
  • 2020-12-23 09:31
    • open /etc/nginx/nginx.conf with write privileges
    • uncomment or add server_names_hash_bucket_size 64;
    • restart nginx sudo service nginx restart

    If the error still persists:

    • increase server_names_hash_bucket_size in steps 128, 256, 512, and so on (increasing by a power of 2 each time). eg. server_names_hash_bucket_size 128;
    • restart the nginx each time until error is gone (error will always be the same no matter what value you already set)
    0 讨论(0)
  • 2020-12-23 09:38

    This is most likely happening because of the long domain name. You can fix this by adding

    server_names_hash_bucket_size  64;
    

    at the top of your http block (probably located in /etc/nginx/nginx.conf). I quote from the nginx documentation what to do when this error appears: In this case, the directive value should be increased to the next power of two. So in your case it should become 64.

    If you still get the same error, try increasing to 128 and further.

    Reference: http://nginx.org/en/docs/http/server_names.html#optimization

    0 讨论(0)
提交回复
热议问题