迹忆客 EN >

当前位置:主页 > 学无止境 > 网络 >

Nginx - 如何修复 “ssl” Directive Is Deprecated, Use “listen … ssl” 错误

作者:迹忆客 最近更新:2023/01/08 浏览次数:

将 nginx 更新到较新版本时,我们可能会遇到不推荐使用的配置。 Nginx 使用类似 YAML 的定义格式来创建配置。 这种格式随着时间的推移通过添加、删除或更改关键字而变化。

本篇文章介绍如何修复 nginx 的 “ ‘ssl’ Directive Is Deprecated, Use ‘listen … ssl’ ” 错误。


Deprecation Warning 弃用警告

使用 nginx -t 检查 nginx 配置时,我们可能会看到以下警告消息:

$ 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  

更新 nginx 后可能会出现此消息。 但是,出现此问题也不必惊慌,我们可以快速修复它!


修复“ssl” Directive Is Deprecated, Use “listen … ssl”

Deprecation Warning 告诉我们要重新配置 SSL 设置。 在 nginx 1.10(及更低版本)中,使用 ssl on; 来配置 SSL。 下面是它的工作原理:

server {  
    listen 80;
    listen 443;

    server_name futurestud.io;

    ssl on;
}

此设置在 nginx 1.12(及更高版本)中已经更改了。 我们现在需要在与 listen 语句相同的行中配置 SSL。 此外,ssl on; 设置不再可用。 可以删除它。

现在修改配置文件如下

server {  
    listen 80;
    listen 443 ssl;

    server_name futurestud.io;

    # ssl on;
}

再次检查我们的 nginx 配置来验证它是否已正确配置:

$ sudo nginx -t  

最后,我们可以重新加载 nginx 服务从而使更改生效。 本篇文章中所做的维护更改不会改变 nginx 的实际行为。 正在从弃用的功能转移到 nginx 的优化配置选项:

$ sudo service nginx reload  

转载请发邮件至 1244347461@qq.com 进行申请,经作者同意之后,转载请以链接形式注明出处

本文地址:

相关文章

How to Install Nginx on Ubuntu 20.04?

发布时间:2025/04/07 浏览次数:157 分类: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.

Install WordPress with Nginx on Ubuntu 18.04

发布时间:2025/04/07 浏览次数:86 分类: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

发布时间:2025/03/26 浏览次数:167 分类: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

发布时间:2025/03/26 浏览次数:132 分类: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

发布时间:2025/03/18 浏览次数:198 分类: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

发布时间:2025/03/18 浏览次数:56 分类: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

发布时间:2025/03/17 浏览次数:195 分类: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

发布时间:2025/03/17 浏览次数:98 分类: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

扫一扫阅读全部技术教程

社交账号
  • https://www.github.com/onmpw
  • qq:1244347461

最新推荐

教程更新

热门标签

扫码一下
查看教程更方便