Nginx - How to fix the "ssl" Directive Is Deprecated, Use "listen ... ssl" error
When updating nginx to a newer version, we may encounter deprecated configurations. Nginx uses a YAML-like definition format to create configurations. This format has evolved over time by adding, removing, or changing keywords.
This article describes how to fix the nginx " 'ssl' Directive Is Deprecated, Use 'listen … ssl' " error.
Deprecation Warning
When checking the nginx configuration using nginx -t, we may see the following warning message:
$ 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 appear after updating nginx. However, don’t panic if this happens, we can fix it quickly!
Fix “ssl” Directive Is Deprecated, Use “listen … ssl”
The Deprecation Warning tells us to reconfigure our SSL settings. In nginx 1.10 (and earlier), ssl on;
SSL is configured using . Here is how it works:
server {
listen 80;
listen 443;
server_name futurestud.io;
ssl on;
}
This setting has changed in nginx 1.12 (and later). We now need to configure SSL in the same line as the listen statement. Also, ssl on;
the setting is no longer available. It can be removed.
Now modify the configuration file as follows
server {
listen 80;
listen 443 ssl;
server_name futurestud.io;
# ssl on;
}
Let's check our nginx configuration again to verify that it is configured correctly:
$ sudo nginx -t
Finally, we can reload the nginx service for the changes to take effect. The maintenance changes made in this article do not change the actual behavior of nginx. Moving from deprecated features to optimized configuration options for nginx:
$ sudo service nginx reload
For reprinting, please send an email to 1244347461@qq.com for approval. After obtaining the author's consent, kindly include the source as a link.
Related Articles
Nginx load balancing settings
Publish Date:2025/03/18 Views:198 Category:NETWORK
-
At this stage, load balancing is a widely used technology. Nginx, as a load balancing server for http, is being used more and more widely. There are three ways to set up Nginx load balancing: Round-robin - This method distributes access req
Nginx load balancing health_check analysis
Publish Date:2025/03/18 Views:54 Category:NETWORK
-
In Nginx load balancing, it is difficult to guarantee that every application server can run normally all the time. However, we can set Nginx to detect these application servers and detect which of them are inaccessible. There are two ways t
HTTP2 Tutorial - How to Configure HTTP2 with Nginx
Publish Date:2025/03/17 Views:195 Category:NETWORK
-
HTTP2 was officially released in 2015. If your website is still using HTTP/1.1, you may be out of date. Don't worry, here we will see how to use Nginx to upgrade your website to HTTP2. Install Nginx I feel that this column is redundant. Sin
Deep understanding of Nginx's server block selection algorithm
Publish Date:2025/03/17 Views:95 Category:NETWORK
-
Nginx is one of the most popular web servers in the world. It can successfully handle high loads with many concurrent client connections and can be used as a web server, mail server, or reverse proxy server. In this article, we will discuss
In-depth understanding of Nginx Location block matching algorithm
Publish Date:2025/03/17 Views:61 Category:NETWORK
-
Similar to the process that Nginx uses to select the Server block that will handle a request , Nginx also has an established algorithm to decide which Location block within a Server block to use to handle a request. location block syntax
How to fix the Unknown "connection_upgrade" Variable error in Nginx
Publish Date:2025/03/17 Views:91 Category:NETWORK
-
When using Websockets or configuring a server with nginx, we may encounter the `$connection_upgrade` variable in the nginx configuration. The $connection_upgrade variable is not available by default. However, it is recommended to define and use it in
How to fix Response Status 0 Worker Process Exited on Signal 11 in Nginx
Publish Date:2025/03/17 Views:81 Category:NETWORK
-
Actually, let's clarify first: HTTP does not have status code 0 (zero). The problem is that the nginx worker process died while handling the request, so the connection was broken, resulting in an error without any response data.
Nginx is running but not serving sites
Publish Date:2025/03/17 Views:86 Category:NETWORK
-
We recently installed nginx version 1.17 on a new machine. The configuration created in sites-available` was symlinked to `sites-enabled`, but nginx is not serving any domains.
How Nginx and uWISG servers work together
Publish Date:2025/03/17 Views:70 Category:NETWORK
-
Nginx and uWISG are two commonly used server software that can work together to provide more stable and efficient network services. This article will introduce in detail the working principle of Nginx and uWISG, and how to configure them to achieve op