• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Resolved nginx "server_names_hash_bucket_size" directive is duplicate

LucaB.

Basic Pleskian
Hi,
I created a new domain with this settings: php version 5.4.16 OS vendor, php runs as FPM appliucation served by nginx. But when I saved it I got this error:

[warn] 12776#0: could not build optimal server_names_hash, you should increase either server_names_hash_max_size: 2526 or server_names_hash_bucket_size: 64; ignoring server_names_hash_bucket_size
[emerg] 12796#0: "server_names_hash_bucket_size" directive is duplicate in /etc/nginx/conf.d/aa500_psa_tweaks.conf:2

and every websites showed 404 error nginx. Then I commented the second line of /etc/nginx/conf.d/aa500_psa_tweaks.conf and run this commands:

/usr/local/psa/admin/bin/nginxmng --disable
/usr/local/psa/admin/bin/nginxmng --enable
/usr/local/psa/admin/bin/nginxmng --status
/usr/local/psa/admin/sbin/httpdmng --reconfigure-all

and every websites returned to work but now in /etc/nginx/conf.d/aa500_psa_tweaks.conf I have the same line again "server_names_hash_bucket_size 128" and i get this error with red background:

"New configuration files for the Apache web server were not created due to the errors in configuration templates: nginx: [emerg] "server_names_hash_bucket_size" directive is duplicate in /etc/nginx/conf.d/aa500_psa_tweaks.conf:3 nginx: configuration file /etc/nginx/nginx.conf test failed . Detailed error descriptions were sent to you by email. Please resolve the issues and click here to generate broken configuration files once again or here to generate all configuration files. See the details in Configuration Troubleshooter"

I commented the directive server_names_hash_bucket_size in /etc/nginx/nginx.conf

Why? Can you help me?

Luca
Plesk 12.5.30 #62 with IP Adress Banning and Web Application Firewall (nginx + apache served ~70 websites)
 
Hi LucaB.,

you added an additional configuration file "/etc/nginx/conf.d/aa500_psa_tweaks.conf"

Consider to SEARCH for all modifications by using a "find command" as for example:
Code:
find /etc/nginx -type f -name "*.conf" -exec grep --color -Hni "server_names_hash_bucket_size"  {} \;
find /etc/nginx -type f -name "*.conf" -exec grep --color -Hni "server_names_hash_max_size"  {} \;
and eliminate double entries.

If you need further help here, pls. don't describe what you did, because we can't investigate possible misconfiguration with guessings. Instead, pls. post all your configuration files, so that we are able to investigate the issue and root cause together with you. ;)
 
Thank you for your answer but I never added that directive or I don't remember. Like you suggest I've eliminated double entries but something add them again (perhaps nginxmng?) when modify configuration, I report you aa500_psa_tweaks.conf:

Code:
server_names_hash_max_size 2526;
server_names_hash_bucket_size 128;

and nginx.conf:

Code:
#user  nginx;
worker_processes  2;

#error_log  /var/log/nginx/error.log;
#error_log  /var/log/nginx/error.log  notice;
#error_log  /var/log/nginx/error.log  info;

#pid        /var/run/nginx.pid;

include /etc/nginx/modules.conf.d/*.conf;

events {
    worker_connections  4096;
}


http {
    include       mime.types;
    default_type  application/octet-stream;
    server_names_hash_bucket_size 64;
    #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  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;
    #tcp_nodelay        on;

    #gzip  on;
    #gzip_disable "MSIE [1-6]\.(?!.*SV1)";

    server_tokens off;

    include /etc/nginx/conf.d/*.conf;
}

# override global parameters e.g. worker_rlimit_nofile
include /etc/nginx/*global_params;

when I go to webserver Configurations Troubleshooter I read this error again:

Code:
Error: New configuration files for the Apache web server were not created due to the errors in configuration templates: nginx: [emerg] "server_names_hash_bucket_size" directive is duplicate in /etc/nginx/conf.d/aa500_psa_tweaks.conf:2 nginx: configuration file /etc/nginx/nginx.conf test failed.


What can i do?

Luca



Hi LucaB.,

you added an additional configuration file "/etc/nginx/conf.d/aa500_psa_tweaks.conf"

Consider to SEARCH for all modifications by using a "find command" as for example:
Code:
find /etc/nginx -type f -name "*.conf" -exec grep --color -Hni "server_names_hash_bucket_size"  {} \;
find /etc/nginx -type f -name "*.conf" -exec grep --color -Hni "server_names_hash_max_size"  {} \;
and eliminate double entries.

If you need further help here, pls. don't describe what you did, because we can't investigate possible misconfiguration with guessings. Instead, pls. post all your configuration files, so that we are able to investigate the issue and root cause together with you. ;)
 
Hi LucaB.,

if you made sure, that there are no other additional settings, you could consider to move away the file "aa500_psa_tweaks.conf" out of "/etc/nginx/conf.d" and test again the conifguration with for example:

Code:
nginx -t

If you don't experience any issues/errors all is fine and you should reconfigure your webserver configuration files, with the example command:
Code:
/usr/local/psa/admin/sbin/httpdmng --reconfigure-all


Now continue to investigate possible entries in ALL files at "/etc/nginx", with the example commands:
Code:
find /etc/nginx -type f -name "*.*" -exec grep --color -Hni "server_names_hash_bucket_size"  {} \;
find /etc/nginx -type f -name "*.*" -exec grep --color -Hni "server_names_hash_max_size"  {} \;

Continue now as well with your search in the folder "/var/www/vhosts/system", using the example commands:
Code:
find /var/www/vhosts/system -type f -name "*.conf" -exec grep --color -Hni "server_names_hash_bucket_size"  {} \;
find /var/www/vhosts/system -type f -name "*.conf" -exec grep --color -Hni "server_names_hash_max_size"  {} \;
... and if all goes well, you won't get any output for your searches and you can again move back your additional configuration file to "/etc/nginx/conf.d" and the now following reconfiguration should not result in issues/errors/problems. ;)
 
Thanks UFHH01, I've done what you suggest me. I've moved aa500_psa_tweaks.conf in /etc/nginx/aa500_psa_tweaks.conf.bak I've not found that directive any files but the reconfiguration failed. I report you what It said me:
Code:
[root@xxxxx nginx]# nginx -t
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
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
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@xxxxx nginx]# find /etc/nginx -type f -name "*.*" -exec grep --color -Hni "server_names_hash_bucket_size"  {} \;
/etc/nginx/aa500_psa_tweaks.conf.bak:2:server_names_hash_bucket_size 128;
/etc/nginx/nginx.conf:21:    server_names_hash_bucket_size 64;
[root@xxxxx nginx]# find /etc/nginx -type f -name "*.*" -exec grep --color -Hni "server_names_hash_max_size"  {} \;
/etc/nginx/aa500_psa_tweaks.conf.bak:1:server_names_hash_max_size 2526;
[root@xxxxx nginx]# find /var/www/vhosts/system -type f -name "*.conf" -exec grep --color -Hni "server_names_hash_bucket_size"  {} \;
[root@xxxxx nginx]# find /var/www/vhosts/system -type f -name "*.conf" -exec grep --color -Hni "server_names_hash_max_size"  {} \;
[root@xxxxx nginx]# /usr/local/psa/admin/sbin/httpdmng --reconfigure-all
Execution failed.
Command: httpdmng
Arguments: Array
(
    [0] => --reconfigure-domains
    [1] => "here it prints all domains that I don't report"
)

Details: [2017-04-05 10:32:33] ERR [util_exec] proc_close() failed ['/usr/local/psa/admin/bin/nginx-config' '-t'] with exit code [1]
[2017-04-05 10:32:40] ERR [util_exec] proc_close() failed ['/usr/local/psa/admin/bin/nginx-config' '-t'] with exit code [1]
[2017-04-05 10:32:40] ERR [panel] Apache config (14913811220.97631100) generation failed: Template_Exception: nginx: [emerg] "server_names_hash_bucket_size" directive is duplicate in /etc/nginx/conf.d/aa500_psa_tweaks.conf:2
nginx: configuration file /etc/nginx/nginx.conf test failed

file: /usr/local/psa/admin/plib/Template/Writer/Webserver/Abstract.php
line: 75
code: 0
nginx: [emerg] "server_names_hash_bucket_size" directive is duplicate in /etc/nginx/conf.d/aa500_psa_tweaks.conf:2
nginx: configuration file /etc/nginx/nginx.conf test failed

and it created aa500_psa_tweaks.conf in /etc/nginx/conf.d/ again.
I don't understand where I wrong.

Luca
 
Hi LucaB.,

Pls. inspect again your nginx.conf at "/etc/nginx". I can clearly see that you added:
...
http {
include mime.types;
default_type application/octet-stream;
server_names_hash_bucket_size 64;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
...
 
Sorry UFHH01,
I've another problem. In Webserver Configurations Troubleshooter I've this error again:
Code:
Error: New configuration files for the Apache web server were not created due to the errors in configuration templates: nginx: [emerg] "server_names_hash_bucket_size" directive is duplicate in /etc/nginx/conf.d/aa500_psa_tweaks.conf:2 nginx: configuration file /etc/nginx/nginx.conf test failed
and I have two configurations fail:
Code:
File Path   Orig. Template   Related Domain   
   
n/a         nginxWebmail.php   /   
   
n/a         nginx.php           /
I try to rebuilt them, It answers me "Information: Reconfiguration success" but the error remain again.

Thank you for your patient.

Luca
 
Hi LucaB.,

I assume, that you use some CUSTOM templates, am I correct?

Pls. post the output of the following commands from your command line ( as user "root" over SSH ):

Code:
find /usr/local/psa/admin/conf/templates -type f -name "*.php" -exec grep --color -Hni "server_names_hash_bucket_size"  {} \;
find /etc/nginx -type f -name "*.conf" -exec grep --color -Hni "server_names_hash_bucket_size"  {} \;
 
This is the output:
Code:
[root@xxxxx nginx]# find /usr/local/psa/admin/conf/templates -type f -name "*.php" -exec grep --color -Hni "server_names_hash_bucket_size"  {} \;
[root@xxxxx nginx]# find /etc/nginx -type f -name "*.conf" -exec grep --color -Hni "server_names_hash_bucket_size"  {} \;
/etc/nginx/conf.d/aa500_psa_tweaks.conf:2:server_names_hash_bucket_size 128;
[root@xxxxx nginx]#

I've done only some customizations in the subscriptions.
All websites run with php as FPM application served by Apache except some served by Nginx (but I would like to pass them under nginx).
Do you need another information?

Luca
 
Hi LucaB.,

I'm lost at the moment, I have to admit, Luca.
If you can't find a double entry with the "find" - command and made sure that your global nginx.conf hasn't got entries, which are repeated in additional configuration files, I can't see any reason for possible errors, when you recreate the configuration files.
I can only refer to the Plesk Support directly, which might have another idea, what the root cause could be, sorry.:(
 
I think that I've solved it. I deleted two rows in the configurations table of psa database. That rows had the status field set to error, perhaps the result of the misconfiguration. I ran httpdmng --reconfigure-all again.

Luca
 
Last edited:
I have this same problem.
I did not make any changes to my configuration files as asserted by UFHH01.
I'm so lost - since this error occurred no sub-domains will encrypt and I get this error all the time.
All sub-domains redirect to the main plesk login page or a 404 if you explicitly try to get to a file.
 
Back
Top