Skip to content

Comments

修复Nginx指令已废弃的警告#112

Closed
xufuyu wants to merge 3 commits intoMCSManager:mainfrom
xufuyu:main
Closed

修复Nginx指令已废弃的警告#112
xufuyu wants to merge 3 commits intoMCSManager:mainfrom
xufuyu:main

Conversation

@xufuyu
Copy link
Contributor

@xufuyu xufuyu commented Feb 20, 2026

关于
listen 12333 ssl http2; #IPV4
listen [::]:12333 ssl http2; #IPv6
Nginx会提示
root@mcsm:/# nginx -t
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /etc/nginx/conf.d/xxx.conf:4
nginx: [warn] the "listen ... http2" directive is deprecated, use the "http2" directive instead in /etc/nginx/conf.d/xxx.conf:5
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
表明指令已过时
现修复为
listen 12333 ssl; #IPV4
listen [::]:12333 ssl; #IPv6
http2 on; # 独立开启http2,作用于整个server块

Updated Nginx configuration for MCSManager to enable HTTP/2 and adjusted listen directives.
Removed 'http2' from listen directives and added 'http2 on' for both MCSManager Daemon and Panel.
Removed 'http2' from listen directives and enabled http2 separately.
@vercel
Copy link

vercel bot commented Feb 20, 2026

@xufuyu is attempting to deploy a commit to the unitwk's projects Team on Vercel.

A member of the Team first needs to authorize it.

@huangsijun17
Copy link
Contributor

这种写法向下兼容吗?我查到是1.25.1开始才有的。
Nginx,特别是一些发行版的包管理直接安装的Nginx和或一些面板安装的,版本可能是低版本。

@xufuyu
Copy link
Contributor Author

xufuyu commented Feb 21, 2026

这种写法向下兼容吗?我查到是1.25.1开始才有的。
Nginx,特别是一些发行版的包管理直接安装的Nginx和或一些面板安装的,版本可能是低版本。

你提到的这个问题很关键。

 http2 on;  这个指令确实是从 Nginx 1.25.1 版本才开始引入的,目的是替代旧的  listen ... http2  写法。

所以,这个修复方案的兼容性需要分情况讨论:

1. 对于 Nginx ≥ 1.25.1:
新写法完全可用,并且是官方推荐的方式,能彻底消除废弃警告。

2. 对于 Nginx < 1.25.1:
新写法会导致配置解析失败,服务无法启动。这对于使用旧版系统包管理(如 apt、yum)或面板安装 Nginx 的用户来说,确实是个问题。

为了兼顾兼容性,我稍后重新提交一个pr,在文档中注明,供用户依据自己的Nginx版本进行选择。

@xufuyu xufuyu closed this Feb 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants