Fix nginx “ssl” Directive Is Deprecated, Use “listen … ssl”

The Warning Message

When you updating nginx to a newer version, you may run into deprecated configurations.

This tutorial shows you how to fix nginx’s “ssl” deprecation warning telling you to use “listen … ssl” instead.

You may see the following warning message when checking your nginx configuration:

$ sudo nginx -t

nginx: [warn] the "ssl" directive is deprecated, use the "listen ... ssl" directive instead in /etc/nginx/sites-enabled/somesite.conf:8

nginx: configuration file /etc/nginx/nginx.conf test failed  

This message may show up after updating the nginx version. The good thing: you can quickly fix it!

Fix “ssl” Directive Is Deprecated, Use “listen … ssl”

The deprecation warning tells you to reconfigure your nginx SSL settings. In nginx 1.10 (and below) you configured SSL using the ssl on; setting. Here’s how it worked:

server {  
    listen 80;
    listen 443;

    server_name futurestud.io;

    ssl on;
}

This setting changed in nginx 1.12 (and above). You now need to configure SSL in the same line as the listen statement. Also, the ssl on; setting is no longer available. You can remove it.

Change your nginx ssl configuration to:

server {  
    listen 80;
    listen 443 ssl;

    server_name futurestud.io;

    # ssl on;
}

Check your nginx config again to verify that it’s correctly configured:

sudo nginx -t  

Finally, you can may reload the nginx service to populate the configuration changes. The maintenance changes made in this tutorial don’t change the actual behavior of nginx. You’re moving from deprecated functionality to nginx’s refined configuration options:

sudo service nginx reload  

That’s all!


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *