JIYIK CN >

Current Location:Home > Learning > NETWORK >

Nginx - How to fix the "ssl" Directive Is Deprecated, Use "listen ... ssl" error

Author:JIYIK Last Updated:2025/03/14 Views:

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.

Article URL:

Related Articles

Nginx 和 uWISG 服务器之间如何配合工作的

Publish Date:2023/03/29 Views:234 Category:网络

Nginx和uWISG是两个常用的服务器软件,它们可以协同工作以提供更加稳定和高效的网络服务。本文将详细介绍Nginx和uWISG之间的配合工作原理,以及如何配置它们以实现最佳性能。 一、

设置 PHP-FPM 和 Nginx Docker 容器

Publish Date:2023/03/29 Views:193 Category:PHP

在本篇文章中,我们将讨论在 Docker 上进行本地开发时如何设置 PHP、PHP-FPM 和 NGINX 容器。

在 Ubuntu 18.04 上使用 Nginx 安装 WordPress

Publish Date:2022/10/15 Views:314 Category:操作系统

WordPress 是最受欢迎的开源内容管理系统 (CMS) 之一,与 Drupal 或 Joomla 等其他 CMS 相比,其市场份额高达 60%。 WordPress 可用于开发任何类型的网站,无论是博客、小型企业还是大型企业。

Nginx 运行但是不提供站点服务

Publish Date:2022/05/15 Views:228 Category:网络

我们最近在一台新机器上安装了 nginx 版本 1.17。 在 sites-available`中创建的配置被符号链接到 `sites-enabled` ,但 nginx 没有为任何域名提供服务。

深入理解 Nginx Location 块匹配算法

Publish Date:2022/01/15 Views:104 Category:网络

与 Nginx 用于选择将处理请求的 Server 块的过程类似,Nginx 也有一个既定的算法来决定 Server 块中的哪个 Location 块用于处理请求。

Scan to Read All Tech Tutorials

Social Media
  • https://www.github.com/onmpw
  • qq:1244347461

Recommended

Tags

Scan the Code
Easier Access Tutorial