Nginx Configuration Problem

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? Thanks.

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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

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! Regards, Bobby