Nginx Configuration Problem

Posted November 10, 2020 1.2k views

I made Nginx configuration. I got error message after this command: sudo nginx -t && sudo systemctl reload nginx
Error Message:

nginx: [emerg] "server_tokens" directive is duplicate in /etc/nginx/conf.d/dokku.conf:3
nginx: configuration file /etc/nginx/nginx.conf test failed


server_tokens off;

# Settings from
ssl_session_cache   shared:SSL:20m;
ssl_session_timeout 1d;
ssl_session_tickets off;

ssl_dhparam /etc/nginx/dhparam.pem;
ssl_ciphers ECDHE-ECDSA-AE.......


# Generated by

user                 www-data;
pid                  /run/;
worker_processes     auto;
worker_rlimit_nofile 65535;

events {
    multi_accept       on;
    worker_connections 65535;

http {
    charset              utf-8;
    sendfile             on;
    tcp_nopush           on;
    tcp_nodelay          on;
    server_tokens        off;
     log_not_found        off;
    types_hash_max_size  2048;
    client_max_body_size 16M;

    # MIME
    include              mime.types;
    default_type         application/octet-stream;

    # Logging
    access_log           /var/log/nginx/access.log;
    error_log            /var/log/nginx/error.log warn;

    # SSL
    ssl_session_timeout  1d;
    ssl_session_cache    shared:SSL:10m;
    ssl_session_tickets  off;

    # Diffie-Hellman parameter for DHE ciphersuites
    ssl_dhparam          /etc/nginx/dhparam.pem;
     ssl_protocols        TLSv1.2 TLSv1.3;
    ssl_ciphers          ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA$

    # OCSP Stapling
    ssl_stapling         on;
    ssl_stapling_verify  on;
    resolver    208.67.$
    resolver_timeout     2s;

    # Load configs
    include              /etc/nginx/conf.d/*.conf;
    include              /etc/nginx/sites-enabled/*;

How can I fix this problem?

edited by MattIPv4

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

Hi there @mervecse,

It seems like that you have the server_tokens defined in both your dokku.conf and nginx.conf.

What you could do is just remove the server_tokens line from your dokku.conf file as you already have it defined for the http directive in your main Nginx config file.

Let me know how it goes!

I’ve removed servertokens and gave error for dublicate sslsessioncache. Then, I’ve removed all duplicate data. But I still have error.
nginx: [emerg] BIO
newfile(“/etc/letsencrypt/live/”) failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen(’/etc/letsencrypt/live/’,‘r’) error:2006D080:BIO routines:BIOnew_file:no such file)
nginx: configuration file /etc/nginx/nginx.conf test failed