Archived
refactor: replace bundled Caddy with external Nginx and Certbot
This commit is contained in:
13 files changed
+312
-77
No files matched your search
+12
-2
@@ -2,9 +2,19 @@
|
||||
|
||||
## Trust and data boundaries
|
||||
|
||||
Public HTTPS reaches Caddy first. Caddy sends product UI, session, administration, health, and REST API routes to the Go service. Standards discovery, OAuth authorization, public JMAP, mail-client configuration, and ACME challenge routes go to Stalwart. Mail protocols reach Stalwart directly on their dedicated TLS-capable ports, so Stalwart obtains its own certificate for SMTP and IMAP while Caddy independently manages the public web certificate.
|
||||
Public HTTPS reaches host-managed Nginx first. Nginx sends product UI, session,
|
||||
administration, health, and REST API routes to the loopback MEOVV upstream.
|
||||
Standards discovery, OAuth authorization, public JMAP, and mail-client
|
||||
configuration routes go to the loopback Stalwart HTTP upstream. Neither upstream
|
||||
port is publicly bound.
|
||||
|
||||
The branded sign-in form posts the password directly to same-origin `/api/auth`, which Caddy routes to Stalwart. The browser creates a PKCE verifier and sends only the one-time authorization code and verifier to MEOVV. The Go service exchanges that code, encrypts access and refresh tokens with AES-GCM, and returns an opaque Secure, HttpOnly, SameSite cookie. User passwords are never sent to or persisted by MEOVV.
|
||||
Mail protocols reach Stalwart directly on their dedicated TLS-capable ports.
|
||||
Certbot remains the single certificate authority client: its deploy hook copies
|
||||
the hostname certificate into the appliance's protected `secrets/tls` directory.
|
||||
Stalwart loads that certificate through file-backed `Certificate` fields for
|
||||
SMTP and IMAP, while Nginx reads the original Certbot lineage for HTTPS.
|
||||
|
||||
The branded sign-in form posts the password directly to same-origin `/api/auth`, which Nginx routes to Stalwart. The browser creates a PKCE verifier and sends only the one-time authorization code and verifier to MEOVV. The Go service exchanges that code, encrypts access and refresh tokens with AES-GCM, and returns an opaque Secure, HttpOnly, SameSite cookie. User passwords are never sent to or persisted by MEOVV.
|
||||
|
||||
Authenticated browser JMAP calls go through `/api/mail/jmap`; discovery goes through `/api/mail/session`; the event stream uses `/api/mail/events`. The Stalwart adapter is the only Go package that knows these upstream routes, which contains pre-1.0 compatibility changes.
|
||||
|
||||
|
||||
+9
-1
@@ -4,9 +4,17 @@
|
||||
|
||||
Direct delivery is the default. Use it only when the host has a stable public IP, outbound TCP 25, correct PTR, and an IP range suitable for email. Relay mode sends through an authenticated TLS smart host and is the supported fallback. Changing mode does not require reinstalling; update the delivery configuration and run diagnostics before switching traffic.
|
||||
|
||||
## Edge proxy and certificates
|
||||
|
||||
Nginx and Certbot are operated outside Compose. The required path split,
|
||||
loopback bindings, initial certificate registration, and renewal hook are in
|
||||
[`nginx-certbot.md`](nginx-certbot.md). After every Nginx or certificate-policy
|
||||
change, verify HTTPS plus TLS on ports 465 and 993; success on HTTPS alone does
|
||||
not prove mail clients receive the renewed certificate.
|
||||
|
||||
## Backups and restore drills
|
||||
|
||||
`mailctl backup` stops the two data writers, archives every named volume and the host configuration/secrets, computes checksums, and starts the services again. Copy the resulting directory to storage that is encrypted, access-controlled, and separate from the mail host.
|
||||
`mailctl backup` stops the two data writers, archives the three appliance volumes and appliance configuration/secrets, computes checksums, and starts the services again. Nginx configuration and the canonical Certbot lineage are external host state and must be covered by the host's backup policy. Copy the resulting directory to storage that is encrypted, access-controlled, and separate from the mail host.
|
||||
|
||||
Run a restore drill for every release:
|
||||
|
||||
|
||||
+7
-2
@@ -11,14 +11,19 @@
|
||||
- Email HTML is sanitized, remote content is blocked by default, and attachment filenames are reduced to safe basenames.
|
||||
- Webhooks require public HTTPS and reject loopback, private, link-local, unspecified, and multicast resolutions.
|
||||
- External webhooks sign `{timestamp}.{raw_body}` with HMAC-SHA256 and retain event IDs across retries.
|
||||
- Caddy adds HSTS; the application adds CSP, anti-framing, MIME-sniffing, referrer, and permissions policies.
|
||||
- The provided Nginx template adds HSTS and response hardening; the application adds CSP, anti-framing, MIME-sniffing, referrer, and permissions policies.
|
||||
- Only 25, 465, 587, and 993 are published for mail. POP3 and plaintext IMAP are absent.
|
||||
|
||||
## Deployment invariants
|
||||
|
||||
Before exposure, confirm that unauthenticated SMTP cannot relay to a third-party domain, sender authorization is enforced on submission, recovery administrator access is removed, and Stalwart's spam/phishing, SPF, DKIM, DMARC, TLS, abuse-ban, and rate-limit defaults remain enabled.
|
||||
|
||||
The internal Docker network is not a trust substitute. Stalwart delivery events use a separate shared HMAC secret. The Stalwart management API is not routed publicly by Caddy; administrators use the authenticated Go adapter.
|
||||
The internal Docker network is not a trust substitute. Stalwart delivery events use a separate shared HMAC secret. The Stalwart management API is not routed publicly by Nginx; administrators use the authenticated Go adapter. Compose binds recovery HTTP to loopback only, and `mailctl configure-tls` rejects non-loopback management URLs before sending the temporary recovery credential.
|
||||
|
||||
The operator must configure Stalwart to trust forwarded HTTP headers only from
|
||||
the exact Docker bridge used by the host Nginx connection. Never trust arbitrary
|
||||
public networks, and never publish the Stalwart HTTP binding on a non-loopback
|
||||
host address.
|
||||
|
||||
## Audit and response
|
||||
|
||||
|
||||
Reference in new issue
Block a user