Certbot 触发 nginx 重复监听

Certbot 触发 nginx 重复监听

我正在尝试将 Certbot 与我的 nginx 应用程序一起使用,但每次运行sudo certbot --nginx并选择“1:尝试重新安装此现有证书”时都会出现此错误:

Deploying Certificate to VirtualHost /etc/nginx/sites-enabled/nycrussian
nginx: [emerg] a duplicate listen [::]:443 in /etc/nginx/sites-enabled/nycrussian:16
Rolling back to previous server configuration...
nginx restart failed:
b''
b''

IMPORTANT NOTES:
 - We were unable to install your certificate, however, we
   successfully restored your server to its prior configuration.

我读过这是由于使用ivp6only或默认页面造成的,我删除了默认配置,只有一个实例[::]:443

这是我的配置(我还设置了从 80 到 443 的端口转发):

server {
    listen 80 default_server;
    server_name _;
    return 301 https://$host$request_uri;
}

server {
    listen [::]:443 ipv6only=off;
    server_name nycrussian.com;

    location / {
        include proxy_params;
        proxy_pass http://unix:/root/RussianInstitute/nycrussian.sock;
    }
}

结果如下grep -R 443 /etc/nginx

/etc/nginx/sites-enabled/nycrussian:    listen [::]:443 ipv6only=off;
/etc/nginx/sites-available/nycrussian:    listen [::]:443 ipv6only=off;

它们是相互联系的。

另外,nginx -t收益为:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

相关内容