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
- How To Install the Newest Version of Nginx on Ubuntu
- How to Run GitLab with Self-Signed SSL Certificate
- How to Fix Reponse Status 0 (Worker Process Exited on Signal 11)
- Redirect Only Root URL Path
- Remove an App/Domain from Sites-Enabled
- How to Serve a Static HTML Page
- Is Running but Not Serving Sites
- How to Fix Unknown "connection_upgrade" Variable
- How to Configure Nginx SSL Certifcate Chain
- How to Fix Nginx SSL PEM_read_bio:bad end line
- How to Remove PEM Password From SSL Certificate
- How to Fix “ssl” Directive Is Deprecated, Use “listen … ssl”
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!