Repository: Mailu/Mailu

Issue:
SSL fails for all domains if a single domain fails LetsEncrypt challenge
## Before you open your issue
- [X] Check if no issue or pull-request for this already exists.
- [X] Check [documentation](https://mailu.io/master/) and [FAQ](https://mailu.io/master/faq.html). 
- [X] You understand `Mailu` is made by volunteers in their **free time** — be conscise, civil and accept that delays can occur.
- [X] The title of the issue should be short and simple.
- 
## Environment & Versions
### Environment
 - [X] docker compose
 - [ ] kubernetes
 - [ ] docker swarm

### Versions
```
1.9
```

## Description
I used [mailu setup utility](https://setup.mailu.io/1.9/) to create a docker-compose.yml with multiple email domains. Turns out not all domains were already pointing to the server IP, so some challenges failed. This leads to nginx closing port 443. So even the main domain is not reachable via SSL.

After removing the non-working domains the cert is created successfully and SSL is working.

## Replication Steps
Create a new mailu setup, add multiple domains of which some are not pointing to the server.

## Expected behaviour
There should be a certificate for the domains that are reachable and nginx should make those accessible with SSL on port 443.

## Logs
```
2022-10-05T19:47:24.203180336Z   Domain: email.example.com
2022-10-05T19:47:24.203182530Z   Type:   dns
2022-10-05T19:47:24.203184754Z   Detail: no valid A records found for email.example.com; no valid AAAA records found for email.example.com
2022-10-05T19:47:24.203187149Z
2022-10-05T19:47:24.203189393Z Hint: The Certificate Authority couldn't exterally verify that the standalone plugin completed the required http-01 challenges. Ensure the plugin is configured correctly and that the changes it makes are accessible from the internet.
2022-10-05T19:47:24.203192008Z
2022-10-05T19:47:24.702017069Z 2022/10/05 21:47:24 [notice] 1#1: signal 1 (SIGHUP) received from 22, reconfiguring
2022-10-05T19:47:24.702118810Z 2022/10/05 21:47:24 [notice] 1#1: reconfiguring
2022-10-05T19:47:24.705542967Z 2022/10/05 21:47:24 [warn] 1#1: conflicting server name "" on 0.0.0.0:80, ignored
2022-10-05T19:47:24.705911789Z 2022/10/05 21:47:24 [notice] 1#1: using the "epoll" event method
2022-10-05T19:47:24.706081756Z 2022/10/05 21:47:24 [notice] 1#1: start worker processes
2022-10-05T19:47:24.706331032Z 2022/10/05 21:47:24 [notice] 1#1: start worker process 23
2022-10-05T19:47:24.706639951Z 2022/10/05 21:47:24 [notice] 1#1: start worker process 24
2022-10-05T19:47:24.706852248Z 2022/10/05 21:47:24 [notice] 1#1: start worker process 25
2022-10-05T19:47:24.730032307Z Hook 'post-hook' ran with output:
2022-10-05T19:47:24.730052144Z  Missing cert or key file, disabling TLS
2022-10-05T19:47:24.730291842Z Hook 'post-hook' ran with error output:
2022-10-05T19:47:24.730302613Z  nginx: [warn] conflicting server name "" on 0.0.0.0:80, ignored
2022-10-05T19:47:24.732101009Z Some challenges have failed.
2022-10-05T19:47:24.732342892Z Ask for help or search for solutions at https://community.letsencrypt.org. See the logfile /var/log/letsencrypt/letsencrypt.log or re-run Certbot with -v for more details.
```



Discussion:

Resolving patch:
diff --git a/core/nginx/letsencrypt.py b/core/nginx/letsencrypt.py
--- a/core/nginx/letsencrypt.py
+++ b/core/nginx/letsencrypt.py
@@ -15,6 +15,7 @@
     "--cert-name", "mailu",
     "--preferred-challenges", "http", "--http-01-port", "8008",
     "--keep-until-expiring",
+    "--allow-subset-of-names",
     "--renew-with-new-domains",
     "--config-dir", "/certs/letsencrypt",
     "--post-hook", "/config.py"
@@ -28,6 +29,7 @@
     "--cert-name", "mailu-ecdsa",
     "--preferred-challenges", "http", "--http-01-port", "8008",
     "--keep-until-expiring",
+    "--allow-subset-of-names",
     "--key-type", "ecdsa",
     "--renew-with-new-domains",
     "--config-dir", "/certs/letsencrypt",


Test patch: