Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
578 views
in Technique[技术] by (71.8m points)

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

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 already have 2 other domains in there and it works fine, but when I try to add the above mentioned domain and start the server it gives me Job failed. See system journal and 'systemctl status' for details. I thought it was because of the dashes, so I tried just various other domains with and without hyphens, but no luck. Same error. what could be causing this? I also tried rebooting, I am really at a loss here. Any help would be greatly appreciated.

I have played around a bit and found out, that, when I only put one domain in, it works. But when I put another domain in, it stops. Here is the output in status:

[root@netzmelone nginx]# systemctl status nginx
nginx.service - A high performance web server and a reverse proxy server
      Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled)
      Active: failed (Result: exit-code) since Sun, 16 Dec 2012 11:38:08 +0000; 7s ago
     Process: 14239 ExecStop=/usr/sbin/nginx -g pid /run/nginx.pid; -s quit (code=exited, status=1/FAILURE)
     Process: 14232 ExecStart=/usr/sbin/nginx -g pid /run/nginx.pid; daemon on; master_process on; (code=exited, status=0/SUCCESS)
     Process: 14242 ExecStartPre=/usr/sbin/nginx -t -q -g pid /run/nginx.pid; daemon on; master_process on; (code=exited, status=1/FAILURE)
    Main PID: 14234 (code=exited, status=0/SUCCESS)
      CGroup: name=systemd:/system/nginx.service

Dec 16 11:38:08 netzmelone nginx[14242]: nginx: [emerg] could not build the server_names_hash, you should increase server_names_hash_bucket_size: 32
Dec 16 11:38:08 netzmelone nginx[14242]: nginx: configuration file /etc/nginx/nginx.conf test failed
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...