Where is the nginx configuration server_names_hash_max_size placed?
高洛峰
高洛峰 2017-05-16 17:18:01
0
1
1339

The operating system is centos 7.2, use

# /usr/sbin/nginx -s reload

When reloading the nginx configuration, the following information is displayed:

[root@i001 ~]# /usr/sbin/nginx -s reload
nginx: [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

Let addserver_names_hash_max_size: 512,
or
server_names_hash_bucket_size: 64,
Ignore
server_names_hash_bucket_size,
The question is:
1. In what file does it need to be added?
2. What is the format? Is there a semicolon or something like that? I tried it but it was always wrong.
3. Ignoreserver_names_hash_bucket_sizeDoes it mean to delete this item when you see it?

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(1)
给我你的怀抱

Solution

Add this sentence to http{} in /usr/local/nginx/conf/nginx.conf

 server_names_hash_max_size 512;

Use sudo /usr/local/nginx/sbin/nginx -t to check the nginx configuration file, if there is still a prompt

could not build the server_names_hash, you should increase either server_names_hash_max_size: 512 or server_names_hash_bucket_size: 64

Then increase server_names_hash_max_size

 server_names_hash_max_size 1024;

Error reason

The hash table that saves server names is controlled by the instructions server_names_hash_max_size and server_names_hash_bucket_size. The parameter hash bucket size is always equal to the size of the hash table and is a multiple of the processor cache size. After reducing the number of accesses in memory, it is possible to speed up the search for hash table key values ​​in the processor. If the hash bucket size is equal to the size of the processor cache, then when searching for a key, the number of searches in the memory is 2 in the worst case. The first time is to determine the address of the storage unit, and the second time is to find the key value in the storage unit. Therefore, if Nginx gives a prompt that the hash max size or hash bucket size needs to be increased, the first thing to do is to increase the size of the previous parameter.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!