Pages

Wednesday, February 5, 2020

Nginx server_names_hash_bucket_size

Today I installed nginx to support multiple Server Blocks/Virtual Hosts. When I configured the second or third Server Block and restarted Nginx, I encountered the following error:

# systemctl start nginx
Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xe" for details.


journalctl only gave me the same error as the Nginx log did:

# journalctl -xe
-- Unit nginx.service has begun starting up.
Feb 04 19:14:17 op01 nginx[13528]: nginx: [emerg] could not build server_names_hash, you should increase server_names_hash_bucket_size: 32
Feb 04 19:14:17 op01 nginx[13528]: nginx: configuration file /etc/nginx/nginx.conf test failed
Feb 04 19:14:17 op01 systemd[1]: nginx.service: Control process exited, code=exited status=1
Feb 04 19:14:17 op01 systemd[1]: Failed to start A high performance web server and a reverse proxy server.
...

# cat /var/log/nginx/error.log
2020/02/04 19:14:17 [emerg] 13528#13528: could not build server_names_hash, you should increase server_names_hash_bucket_size: 32


To make it short: even though I only configured the second or third Server Block, the name I used for the Server Block was to long. I needed to increase the value for server_names_hash_bucket_size in the nginx.conf file:

# vi /etc/nginx/nginx.conf
http {
...
        server_names_hash_bucket_size 64;
...
}


After adjusting the value, Nginx started again:

# systemctl start nginx

Links:

http://nginx.org/en/docs/http/server_names.html

No comments:

Post a Comment