在 Arch Linux 上通过包管理命令 pacman
安装了最新的 Nginx,启动时出现了一段警告消息,这里记录一下自己的处理过程和对问题的粗浅了解。
首先来看一下提示消息:
2022/06/04 10:03:07 [warn] 19286#19286: could not build optimal types_hash, you should increase either types_hash_max_size: 1024 or types_hash_bucket_size: 64; ignoring types_hash_bucket_size
解决方法其实就包含在这段提示消息里。只需要在 types_hash_max_size
或是 types_hash_bucket_size
配置项中选择任意一个,设置一个比当前取值更大的数字就行了。至于当前值是多少,上面消息中,每个配置项后的数字就是。
于是我到 nginx.conf 的 http
配置区域中新增了如下一行配置:
types_hash_bucket_size 65;
然后执行 nginx -t
测试了一下,不再出现上面的警告提示。问题就此解决。
通过查阅一些信息,发现这俩配置和 mime types 有点关系,随后我又尝试了一下,如果在 nginx.conf 中注释掉 include mime.types;
这行,或是把 mime.types 文件中的数据删掉一多半,也不会再出现上面的警告消息。
另外根据 Nginx 对于 Hash 配置项的说明,在出现类似的警告消息时,应该优先增加 max size 配置项的值,而不是 bucket size,看来我在上面为了解决问题用的 types_hash_bucket_size
配置项不是最佳选择,应当使用 types_hash_max_size
。
Setting up hashesNginx 官方文档对于 Hash 配置项使用的具体说明。