nginx: [warn] protocol options redefined 的解决方法
报错内容:
nginx: [warn] protocol options redefined for 0.0.0.0:443 in /usr/local/nginx/conf/vhost/mywebsite.com.conf:4
报错原因分析:
server {
listen 80;
listen [::]:80;
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name i.example.com;
}
server {
listen 80;
listen [::]:80;
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name x.example.com;
}
以上的内容会报此错误。因为 ssl
和 http2
只能在一个 server
模块中存在。若在其中的一个已存在,则另外的模块不需要再设置。
解决后最终为
server {
listen 80;
listen [::]:80;
listen 443;
listen [::]:443;
server_name i.example.com;
}
server {
listen 80;
listen [::]:80;
listen 443 ssl http2; # 只能指定一行
listen [::]:443 ssl http2; # 只能指定一行
server_name x.example.com;
}
```