Score:0

Error in multiple domains with nginx when add certboot certificate

in flag

I'm using an Ubuntu 20.04 server on Azure, with Nginx, PHP-FPM, and two websites.
The sites are example.com and sub.example.com and They are with the certificate issued by certbot and working fine.
I added a third site with a different domain example2.com and it worked fine. But when I add certbot to this third site, they all stop working, and Nginx doesn’t stop and doesn't show any error. I added the certificates using this

sudo certbot --Nginx -d example.com -d www.example.com    
sudo certbot --nginx -d sub.example.com

Until here ok, and sites working fine last five months

Then I add a new website and worked fine two, but when I add certbot, all of them stop to work, but nginx still running without errors

sudo certbot --nginx -d example2.com -d www.example2.com

verification of Nginx:

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

Sites only work again if I remove the certificate from the third site

sudo sudo certbot delete --cert-name example2.com

I am sorry, I'm trying my best to use English.

Server block Site 1

server {
        root /var/www/example.com/html;
        index index.php index.html index.htm index.nginx-debian.html;
        server_name example.com www.example.com;
        location / {
                try_files $uri $uri/ /index.php?$args;
        }
        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_pass unix:/run/php/php7.4-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
  }

    listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot


}
server {
    if ($host = www.example.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    if ($host = example.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot
        listen 80 default_server;
        listen [::]:80 default_server;
        server_name example.com www.example.com;
    return 404; # managed by Certbot
}

Server block Site 2 (subdomain site 1)

server {
        root /var/www/sub.example.com/html;
        index index.php index.html index.htm index.nginx-debian.html;
        server_name sub.example.com;
        location / {
                try_files $uri $uri/ /index.php?$args;
        }
        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_pass unix:/run/php/php7.4-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
        }
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/sub.example.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/sub.example.com/privkey.pem; # managed by Certbot
#    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
#    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}
server {
    if ($host = sub.example.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot
        listen 80;
        server_name sub.example.com;
return 404; # managed by Certbot
}

Server block Site 3

server {
        root /var/www/example2.com/html;
        index index.php index.html index.htm index.nginx-debian.html;
        server_name example2.com www.example2.com;
        location / {
                try_files $uri $uri/ =404;
        }
        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_pass unix:/run/php/php7.4-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
  }
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/example2.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/example2.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot


}
server {
    if ($host = www.example2.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    if ($host = example2.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

        listen 80;

        server_name example2.com www.example2.com
    return 404; # managed by Certbot

}

jp flag
You need to describe what exactly you get when your sites "stop working".
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.