大网数据广告活动
服务器运维问答

nginx: [warn] protocol options redefined

· 52CE 我爱测

I'm updated nginx to 1.23.4, and nginx -t start showing warnings: nginx: [warn] protocol options redefined for 0.0.0.0:443 in /etc/nginx/sites-enabled/beta:5 nginx: [warn] protocol options redefined for [::]:443 in /etc/nginx/sit…

问题原文

原帖链接 · bato3 · CC BY-SA 4.0

I'm updated nginx to 1.23.4, and nginx -t start showing warnings:

nginx: [warn] protocol options redefined for 0.0.0.0:443 in /etc/nginx/sites-enabled/beta:5
nginx: [warn] protocol options redefined for [::]:443 in /etc/nginx/sites-enabled/default:28
nginx: [warn] protocol options redefined for [::]:443 in /etc/nginx/sites-enabled/grafana:5

These lines are

    listen 443 ssl;
    listen [::]:443 ssl;
# sometimes:
#    listen 443 ssl;
#    listen [::]:443;
# I'm now know - some inconsistency, fixed

But after tweaking and adding http2 there were more warnings.

社区高分解答

原帖链接 · bato3 · CC BY-SA 4.0

It turned out that I didn't correct the configuration enough. Corrections must be made on all servers configurations.

To find all the wrong occurrences, you can help yourself:

grep -R /etc/nginx/ -e 443 |grep -v ssl
grep -R /etc/nginx/ -e 443 |grep -v http2

Important: All servers listening on the same port should have identical configuration.

eg.:

listen 443 ssl http2;

#bad:  ssl without http2
listen 443 ssl; 

#ok:   identical protocols as in previous (first) server
listen 443 ssl http2; 

More details are in commit: https://github.com/nginx/nginx/commit/dad65f3e449f215469943628f2b1f12a118fcf7e

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2023-05-17)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。