Serve mail autoconfiguration on the bare domain
Deploy instance / deploy (push) Successful in 1s
Lint and reload / lint (push) Successful in 1s
Lint and reload / reload (push) Successful in 0s

Thunderbird asks <domain>/.well-known/autoconfig, Outlook POSTs to
<domain>/Autodiscover, and both fell into portal's catch-all, which
answers 200 with an HTML page - so a client got markup where it expected
XML and went back to guessing.

Both prefixes now go to Stalwart, which already generates the answers,
templated on the address asked about. No static copy to drift out of
date and no hostname of their own to certify. Host is rewritten to the
name Stalwart has always answered for, and all three spellings of
/Autodiscover are matched because Outlook is not consistent about it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015GeH3y8fwTaTudaD88P57o
This commit is contained in:
Bendik Lynghaug
2026-10-07 09:29:06 +02:00
co-authored by Claude Opus 5
parent 15704959ad
commit 30f9025d40
+25
View File
@@ -114,7 +114,32 @@ jobs:
} }
{$DOMAIN} { {$DOMAIN} {
# Mail clients look for their configuration on the bare domain -
# Thunderbird at /.well-known/autoconfig, Outlook by POSTing to
# /Autodiscover. Stalwart already generates both, templated on the
# address asked about, so these two paths go to it instead of being
# copied into this repo: one source of truth, and no second
# hostname to certify. Host is rewritten to the name Stalwart
# answers for; it never sees a request for the bare domain
# otherwise. (MTA-STS cannot be served here - RFC 8461 requires
# mta-sts.<domain> - so it keeps its own record and route.)
handle /.well-known/autoconfig/* {
reverse_proxy stalwart:8080 {
header_up Host mail.{$DOMAIN}
}
}
@autodiscover path /Autodiscover/* /autodiscover/* /AutoDiscover/*
handle @autodiscover {
reverse_proxy stalwart:8080 {
header_up Host mail.{$DOMAIN}
}
}
handle {
reverse_proxy host.docker.internal:3010 reverse_proxy host.docker.internal:3010
}
log { log {
output file /var/log/caddy/www.log output file /var/log/caddy/www.log
} }