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

When updating nginx to a newer version, you may run into deprecated configurations. Nginx uses a YAML-like definition format to create configurations. This format evolves over time by adding, removing, or changing keywords.

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

nginx Series Overview

The Deprecation Warning

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

$ sudo nginx -t

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

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

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

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

The deprecation warning tells you to reconfigure your 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 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 it!

Explore the Library

Find interesting tutorials and solutions for your problems.