I am trying to use Certbot with my nginx application, but every time I run sudo certbot --nginx and select "1: Attempt to reinstall this existing certificate" I get this error:

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.

I've read this is caused by using ivp6only or by default pages, I have deleted the default configuration and have only one instance of [::]:443

Here is my configuration (I also set up port forwarding from 80 to 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;
    }
}

Here are the results of grep -R 443 /etc/nginx:

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

which are linked together.

Also, nginx -t yeilds:

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

0 Answers