4

nginx — 如何修复 “ssl” Directive Is Deprecated, Use “listen … ssl”

 1 year ago
source link: https://blog.p2hp.com/archives/10761
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

nginx — 如何修复 “ssl” Directive Is Deprecated, Use “listen … ssl”

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

本教程向您展示如何修复 nginx 的“ssl” deprecation warning telling you to use “listen … ssl”。

使用以下命令检查 nginx 配置时,您可能会看到以下警告消息nginx -t

$ 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”指令被弃用,使用“listen … ssl”

弃用警告会告诉您重新配置 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;设置不再可用。您可以将其删除。

将您的 nginx 配置更改为:

server {  
    listen 80;
    listen 443 ssl;

    server_name futurestud.io;

    # ssl on;
}

再次检查您的 nginx 配置以验证其配置是否正确:

sudo nginx -t  

最后,您可以重新加载 nginx 服务以填充配置更改。本教程中所做的维护更改不会更改 nginx 的实际行为。您正在从弃用的功能转向 nginx 的改进配置选项:

sudo service nginx reload  

就是这样!


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK