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
How to Install Nginx on Ubuntu 20.04?
Publish Date:2025/04/07 Views:157 Category:OPERATING SYSTEM
-
Nginx is one of the most popular web servers in the world, responsible for hosting some of the largest and most trafficked sites on the Internet. It is a lightweight application software that can be used as a web server or a reverse proxy.
How to use Let's Encrypt with Nginx to configure https in Ubuntu 20.04
Publish Date:2025/04/07 Views:123 Category:OPERATING SYSTEM
-
Let's Encrypt is a Certificate Authority (CA) that provides an easy way to obtain and install free TLS/SSL certificates, enabling encrypted HTTPS on your web server. It simplifies the process by providing a software client, Certbot, which a
Install WordPress with Nginx on Ubuntu 18.04
Publish Date:2025/04/07 Views:86 Category:OPERATING SYSTEM
-
WordPress is one of the most popular open source content management systems (CMS) with a market share of up to 60% compared to other CMS like Drupal or Joomla. WordPress can be used to develop any type of website, be it a blog, a small busi
Solution to incorrect access log time when deploying Nginx in Docker
Publish Date:2025/03/26 Views:165 Category:Docker
-
In the process of operating the website, I never took the logs too seriously. Although logging was turned on, I never analyzed the logs carefully. Today, when I looked at the logs on a whim, I found that the recorded time was 8 hours less t
Docker deploys nginx php application
Publish Date:2025/03/26 Views:131 Category:Docker
-
I'm learning docker recently. I'm learning by building an nginx+php development environment example. Here I record the build process. First, give a docker-compose.yml deployment configuration file version: '3' services: nginx: container_nam
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:56 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:98 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