0

How do I insert the “server_names_hash_bucket_size 64;” in my conf.d file?

The file I want to build for my specific case is /etc/nginx/conf.d/dev.demo.kmdashboard.dashboardsanddatabases.com.conf.

My error

Error while running nginx -c /etc/nginx/nginx.conf -t.

nginx: [emerg] could not build server_names_hash, you should increase server_names_hash_bucket_size: 64
nginx: configuration file /etc/nginx/nginx.conf test failed

This occurs after I tried to sudo certbot --nginx -d dev.demo.kmdashboard.dashboardsanddatabases.com. Now all my attempts to create my /etc/nginx/conf.d/dev.demo.kmdashboard.dashboardsanddatabases.com.conf file with some version of the http{server_...} below are unsuccessful.

http {
    server_names_hash_bucket_size 64;

Here is what I have looked at and tried:

Documentation

I have looked at the documentation here: https://nginx.org/en/docs/http/server_names.html#optimization. I interpreted that there is another http{} section that would include the server_names_hash_bucket_size 64;. I’ve tried variations of this to no avail.

Other Stack Post that looked promising

This post seemed most helpful and aligns with other sources. My best attempt to leverage it's suggestion have been unsuccessful.

My best attempt

The file is /etc/nginx/conf.d/dev.demo.kmdashboard.dashboardsanddatabases.com.conf

http {
    server_names_hash_bucket_size 64;
    http {
        server {

            listen       80;
            listen       [::]:80;
            server_name  dev.demo.kmdashboard.dashboardsanddatabases.com;
            client_max_body_size 30G;
            

            location /static {
                alias /home/sanjose/applications/kmdashboard03_dev/app_package/static;
            }

            location / {
                proxy_pass http://localhost:8007;
                include /etc/nginx/proxy_params;
                proxy_redirect off;
            }
        }
    }
}

Below is the typical structure for files in /etc/nginx/conf.d/ when the urls less than 32 characters.

server {
    listen       80;
    listen       [::]:80;
    server_name  nhtsa-dash.kineticmetrics.com demo.kmdashboard.dashboardsanddatabases.com;
    client_max_body_size 30G;

location /static {
    alias /home/sanjose/applications/kmdashboard03/app_package/static;
}

location / {
    proxy_pass http://localhost:8006;
    include /etc/nginx/proxy_params;
    proxy_redirect off;
}
}

One odd thing is that this last conf.d file is actually being used currently. You'll notice the second url (demo.kmdashboard.dashboardsanddatabases.com) is longer than 32 characters. Maybe I am misunderstanding what the 32 means? It doesn't mean characters?

1
  • The error seems to relate to the value "64". Have you tried increasing the value to "128"? Jul 2 at 7:28

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.