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 和 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 如何修复 Reponse Status 0 Worker Process Exited on Signal 11
Publish Date:2022/05/14 Views:320 Category:网络
-
实际上,让我们首先澄清一下:HTTP 没有状态码 0(零)。 问题是 nginx 工作进程在处理请求时死亡,因此连接中断,导致没有任何响应数据的错误。
Nginx 如何修复 Unknown "connection_upgrade" Variable 错误
Publish Date:2022/03/28 Views:7687 Category:网络
-
在使用 Websockets 或使用 nginx 配置服务器时,我们可能会在 nginx 配置中遇到 `$connection_upgrade` 变量。 $connection_upgrade 变量默认不可用。 但是,建议在反向代理设置中定义和使用它。
Nginx - 如何修复 “ssl” Directive Is Deprecated, Use “listen … ssl” 错
Publish Date:2022/03/23 Views:266 Category:网络
-
本篇文章介绍如何修复 nginx 的 “ ‘ssl’ Directive Is Deprecated, Use ‘listen … ssl’ ” 错误。Nginx 使用类似 YAML 的定义格式来创建配置。 这种格式随着时间的推移通过添加、删除或更改关键
在 Ubuntu 20.04 如何使用 Let's Encrypt 结合 Nginx 配置 https
Publish Date:2022/02/03 Views:651 Category:操作系统
-
在本篇文章中,我们介绍了安装了 Let's Encrypt 客户端 certbot,为我们的域名下载 SSL 证书,配置 Nginx 来使用这些证书,并设置自动证书更新。
深入理解 Nginx Location 块匹配算法
Publish Date:2022/01/15 Views:104 Category:网络
-
与 Nginx 用于选择将处理请求的 Server 块的过程类似,Nginx 也有一个既定的算法来决定 Server 块中的哪个 Location 块用于处理请求。