作者:佚名 时间:2025-03-02 09:27:58 阅读:(21)
最近在升级了服务器nginx版本之后,提示:nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead,这个警告提醒用户该指令已弃用,并建议使用更现代、更合适的配置。
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /usr/local/nginx/conf/ssl.conf:1 nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
Nginx 自从 1.25 版本后,开启http2的配置写法有变更,旧的写法已经被标记为“过时”。
(1)、旧配置(已弃用):
server { listen 443 ssl http2; server_name example.com; # 其他配置 }
(2)、新配置:
server { listen 443 ssl; http2; server_name example.com; # 其他配置 }
(1)、listen 443 ssl;:这行指令让 Nginx 在 443 端口上启用 SSL 加密。
(2)、http2;:这一行是新加入的,用于单独启用 HTTP/2 支持。将其放置在 listen 指令之后,使得配置更加清晰,并符合最新的 Nginx 配置标准。