nginx 出现 type_hash 错误

nginx 出现 type_hash 错误

我正在尝试使用 nginx 提供单个应用程序,但每当我启动它时,都会收到以下错误(和警告):

nginx: [warn] duplicate MIME type "text/html" in /var/www/nginx.conf:33
nginx: [emerg] could not build the types_hash, you should increase either types_hash_max_size: 1024 or types_hash_bucket_size: 32

据我所知,emerg当人们在同一个机器上运行多个服务器时,这种错误很常见,但这是我运行的唯一 nginx 实例。

这是我的配置文件:

user root;
worker_processes 1;

error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;

events {
    worker_connections 1024;
    use epoll;
}

http {
    # Enumerate all the Tornado servers here
    upstream frontends {
        server 127.0.0.1:4000;
    }

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    access_log /var/log/nginx/access.log;

    keepalive_timeout 65;
    proxy_read_timeout 200;
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    gzip on;
    gzip_min_length 1000;
    gzip_proxied any;
    gzip_types text/plain text/html text/css text/xml
               application/x-javascript application/xml
               application/atom+xml text/javascript;

    # Only retry if there was a communication error, not a timeout
    # on the Tornado server (to avoid propagating "queries of death"
    # to all frontends)
    proxy_next_upstream error;

    server {
        listen 80;

        # Allow file uploads
        client_max_body_size 50M;

        location / {
            proxy_pass_header Server;
            proxy_set_header Host $http_host;
            proxy_redirect off;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Scheme $scheme;
            proxy_pass http://frontends;
        }
    }
}

任何关于此问题的帮助都将不胜感激!


我曾尝试添加行

types_hash_max_size 2048;

但我得到了一个错误“你不能把它放在那里。”经过一番挖掘之后,我发现我需要将其放入html配置文件的部分中。

答案1

text/html从字符串中删除类型gzip_typestext/html始终是 gzip 压缩的,您不需要单独指定它。

相关内容