目 录CONTENT

文章目录

nginx 配置报错 could not build server_names_hash, you should increase server_names_hash_bucket_size: 32

过客
2025-06-22 / 0 评论 / 0 点赞 / 5 阅读 / 0 字

修改小米路由中的Nginx配置的时候,遇到报错

2025/06/22 14:08:11 [emerg] 26724#0: could not build server_names_hash, you should increase server_names_hash_bucket_size: 32

这个报错表明 Nginx 在构建服务器名称哈希表时,检测到您配置的 server_name 长度超过了默认的哈希桶大小限制。

解决方法:

在 Nginx 主配置中增加哈希桶大小(​​必须放在 http {} 块内​​):

打开nginx配置文件,如:/etc/nginx/nginx.conf

http {
    # 核心修复配置(增加到 64 或 128,根据域名长度调整)
    server_names_hash_bucket_size 64;
    
    # 可选:如果域名数量非常多(超过 1000 个)
    server_names_hash_max_size 2048;

    # 原有其他配置...
    include /etc/nginx/conf.d/*.conf;
}

详细说明:

指令 作用 推荐值 配置位置
server_names_hash_bucket_size 处理单个域名的存储桶大小 ​64​​(默认32)超长域名需 ​​128​ 必须放在 http {}
server_names_hash_max_size` 域名哈希表总容量 域名数量 x 2(默认512) 可选添加在 http {}

测试

nginx -t
0
  1. 支付宝打赏

    qrcode alipay
  2. 微信打赏

    qrcode weixin

评论区