From 493cc66bed37300cb02c1fa7b6b9c1b169ba4661 Mon Sep 17 00:00:00 2001 From: Meghdad <61308304+MeghdadFadaee@users.noreply.github.com> Date: Thu, 13 Aug 2026 04:10:20 +0330 Subject: [PATCH] fix(installer): treat public HTTP challenge as authoritative --- README.md | 5 ++++- docs/nginx-certbot.md | 5 ++++- scripts/install-server.sh | 10 ++++++---- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index bb65f1e..aeb7fe1 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,10 @@ no redirect. If another proxy, NAT rule, or virtual host intercepts the request, installation stops with a report covering the active Nginx site, public A/AAAA answers, local-origin result, public result, and redirect target. If this host's Nginx does not load `sites-enabled`, the installer automatically tries its -managed `conf.d` fallback before reporting a configuration problem. +managed `conf.d` fallback before reporting a configuration problem. The public +result is authoritative: a different loopback virtual-host result is reported +as a warning but does not block Certbot when the public challenge returns exact +content. Automatic DNS setup creates or updates the mail-host A/AAAA record, the primary MX record, and autoconfiguration CNAMEs. It adds monitoring-mode DMARC and a diff --git a/docs/nginx-certbot.md b/docs/nginx-certbot.md index 22ea077..ee37cb6 100644 --- a/docs/nginx-certbot.md +++ b/docs/nginx-certbot.md @@ -67,7 +67,10 @@ loopback request pinned to local Nginx from a normal public-hostname request and includes public A/AAAA answers and any redirect location. If `sites-enabled` is not loaded, the installer safely retries its managed site through `/etc/nginx/conf.d/meovv-mail.conf`; it does not edit `nginx.conf` or unrelated -virtual hosts. +virtual hosts. The public response is the issuance gate because it matches what +the ACME server can reach. A differing loopback virtual-host response remains a +visible warning but does not block issuance when the public response is `200` +with exact challenge content. It manages the mail hostname's unproxied A/AAAA records, the zone MX record, and the `autoconfig` and `autodiscover` CNAMEs. Existing SPF and DMARC policies are diff --git a/scripts/install-server.sh b/scripts/install-server.sh index 0952848..ae747e0 100755 --- a/scripts/install-server.sh +++ b/scripts/install-server.sh @@ -672,7 +672,7 @@ verify_http_challenge_route() { local challenge_directory challenge_name challenge_file challenge_url local local_body local_headers local_status="000" local_curl_ok local_content_ok local public_body public_headers public_status="000" public_curl_ok public_content_ok - local public_redirect public_ipv4 public_ipv6 + local local_redirect public_redirect public_ipv4 public_ipv6 challenge_directory="$CERTBOT_WEBROOT/.well-known/acme-challenge" challenge_name="meovv-preflight-$(openssl rand -hex 12)" challenge_file="$challenge_directory/$challenge_name" @@ -702,6 +702,7 @@ verify_http_challenge_route() { fi local_content_ok=false cmp -s "$challenge_file" "$local_body" && local_content_ok=true + local_redirect="$(sed -n 's/^[Ll]ocation:[[:space:]]*//p' "$local_headers" | tr -d '\r' | tail -n 1)" public_ipv4="$(dig +short A "$MAIL_HOSTNAME" @1.1.1.1 | paste -sd ',' - || true)" public_ipv6="$(dig +short AAAA "$MAIL_HOSTNAME" @1.1.1.1 | paste -sd ',' - || true)" @@ -729,13 +730,11 @@ HTTP-01 preflight report Public DNS A: ${public_ipv4:-none} Public DNS AAAA: ${public_ipv6:-none} Local origin: status ${local_status:-000}, exact challenge: $local_content_ok + Local redirect: ${local_redirect:-none} Public hostname: status ${public_status:-000}, exact challenge: $public_content_ok Public redirect: ${public_redirect:-none} EOF - if ! $local_curl_ok || [[ "$local_status" != "200" ]] || ! $local_content_ok; then - die "local Nginx does not serve the managed HTTP-01 challenge; inspect the reported active site and port 80 listener" - fi if [[ -z "$public_ipv4$public_ipv6" ]]; then die "$MAIL_HOSTNAME has no public A or AAAA response from resolver 1.1.1.1" fi @@ -745,6 +744,9 @@ EOF fi die "public port 80 does not return the local MEOVV challenge; correct DNS, NAT, firewall, or upstream proxy routing before running Certbot" fi + if ! $local_curl_ok || [[ "$local_status" != "200" ]] || ! $local_content_ok; then + warn "loopback HTTP differs from the public route${local_redirect:+ and redirects to $local_redirect}; the authoritative public challenge passed, so installation can continue" + fi rm -f -- "$challenge_file" "$local_body" "$local_headers" "$public_body" "$public_headers" log "All HTTP-01 checks passed; Certbot may start"