Rootop 服务器运维与web架构

nginx绑定大量域名时需要修改的两个参数

nginx在添加量大虚拟主机时重启nginx报错。

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
http {
    include       mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    # 添加或修改下面2行
    server_names_hash_max_size 4096;
    server_names_hash_bucket_size 1024;

    include vhost/*.conf;
}

原创文章,转载请注明。本文链接地址: https://www.rootop.org/pages/5107.html

作者:Venus

服务器运维与性能优化

评论已关闭。