Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nginx won't start, says "could not build test test_types_hash"

Tags:

nginx

Here's my nginx.conf:

user www-data;
worker_processes 1;
worker_rlimit_nofile 8192;

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

events {
    worker_connections 2048;
    # debug_connection 192.168.1.1;
    # multi_accept on;
}

http {
    server_tokens off;
    include mime.types;

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

    sendfile on;
    tcp_nodelay on;

    gzip on;

    # http://wiki.nginx.org/HttpGzipModule#gzip_disable
    gzip_disable "msie6";
    gzip_types text/javascript text/css text/plain text/xml application/xml application/xml+rss application/x-javascript;

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*.ngx;

    #tcp_nopush on;
    #keepalive_timeout  0;
}

When I try to start nginx, here's what I see:

nginx: [warn] duplicate MIME type "text/javascript" in /etc/nginx/nginx.conf:27
nginx: [emerg] could not build the test_types_hash, you should increase either test_types_hash_max_size: 2048 or test_types_hash_bucket_size: 64

This identical configuration has worked previously with no issues. What am I missing?

like image 245
dwlz Avatar asked Oct 25 '13 00:10

dwlz


2 Answers

After banging my head against the wall for a couple of minutes, I just decided "what the heck, I'll fix the first error and see what happens." Lo and behold, removing the extraneous text/javascript MIME type in the gzip_types declaration fixed the problem.

Hope this is helpful!

like image 84
dwlz Avatar answered Sep 24 '22 19:09

dwlz


For the benefit of anyone arriving here late to the party but not exeriencing that first message:

Your fix of the first error had the side-effect of shortening the line which had caused the second message.

In my own case, the silly mistake was to place the list of MIME types in quotes. Leave them unquoted.

You can't increase the bucket size for the 'test_types_hash' since there isn't a directive (ref. https://trac.nginx.org/nginx/ticket/203) so reducing the list of MIME types is the only option.

Ref. http://nginx.org/en/docs/http/ngx_http_core_module.html#types_hash_bucket_size

like image 31
Ed Randall Avatar answered Sep 24 '22 19:09

Ed Randall