nginx snippet terminates TLS for the server's names: domains added later and TLSA break #48

Closed
opened 2026-11-08 08:22:11 +00:00 by jcoffey-dev · 1 comment
Owner

Reported on the forum (https://community.coffeylabs.org/t/232, post 4) by someone running the server, console and webmail behind their own nginx.

--proxy snippets writes nginx-inbuxa.conf (internal/compose/templates/nginx-inbuxa.conf.tmpl), which has nginx terminate TLS for the mail server's web names with a certificate the operator supplies. Those names are ServerNames() (internal/compose/compose.go): the mail host plus autoconfig., autodiscover., mta-sts. and ua-auto-config. of the install domain, fixed at install time. That breaks in three ways:

  1. Domains added later aren't served. mta-sts.<new domain> and the other service names aren't in nginx, so HTTPS gets the default server and the wrong certificate (MTA-STS policy fetches fail). The port 80 block only passes ACME challenges for the install-time names, so the server's HTTP-01 orders for a new domain's names fail too.
  2. TLSA records don't match. With TLSA publishing on, the server publishes _443._tcp records for the mail host and those service names from its own certificate (crates/common/src/network/dns/records.rs, inbuxa-server). nginx answers 443 with a different one. Browsers don't check, DANE checkers do. The mail ports are unaffected.
  3. Two sets of certificates for the same names: the server's own and nginx's copy, renewed separately.

The reporter's layout fixes all three. nginx's stream module routes on SNI with ssl_preread: the console and webmail names go to an nginx http server on a loopback port that terminates TLS, and every other name is passed through untouched, with PROXY protocol, to the server's own HTTPS listener on loopback. The server then serves its own certificates for any domain, its TLSA records match, and TLS-ALPN-01 reaches it.

Fix:

  • Write the nginx snippet that way: a stream block (ssl_preread, a map of the console and webmail names, default to the server's HTTPS listener, proxy_protocol on), the console and webmail http servers on a loopback port with proxy_protocol and real_ip_header proxy_protocol, and port 80 passing every name's ACME challenges to the server (not just the install-time list).
  • Set up the server side to match: an HTTPS listener on loopback that accepts PROXY protocol from 127.0.0.1 only.
  • Say in the file that it needs nginx's stream module (libnginx-mod-stream on Debian/Ubuntu) and that the server block for 443 goes inside stream { }.
  • Check the Caddy fragment for the same problems (plain Caddy can't route TLS by SNI without the layer4 plugin, so it may need a different answer, or a note).
  • Docs: "Behind your own web server" in the installer guide (inbuxa.org docs-site/content/docs/install/installer.md) should say what happens with domains added later and with TLSA.
  • e2e: add a second domain after install and check its mta-sts. name gets the server's certificate through the snippet.
Reported on the forum (https://community.coffeylabs.org/t/232, post 4) by someone running the server, console and webmail behind their own nginx. `--proxy snippets` writes `nginx-inbuxa.conf` (`internal/compose/templates/nginx-inbuxa.conf.tmpl`), which has nginx terminate TLS for the mail server's web names with a certificate the operator supplies. Those names are `ServerNames()` (`internal/compose/compose.go`): the mail host plus `autoconfig.`, `autodiscover.`, `mta-sts.` and `ua-auto-config.` of the install domain, fixed at install time. That breaks in three ways: 1. **Domains added later aren't served.** `mta-sts.<new domain>` and the other service names aren't in nginx, so HTTPS gets the default server and the wrong certificate (MTA-STS policy fetches fail). The port 80 block only passes ACME challenges for the install-time names, so the server's HTTP-01 orders for a new domain's names fail too. 2. **TLSA records don't match.** With TLSA publishing on, the server publishes `_443._tcp` records for the mail host and those service names from its own certificate (`crates/common/src/network/dns/records.rs`, inbuxa-server). nginx answers 443 with a different one. Browsers don't check, DANE checkers do. The mail ports are unaffected. 3. **Two sets of certificates** for the same names: the server's own and nginx's copy, renewed separately. The reporter's layout fixes all three. nginx's `stream` module routes on SNI with `ssl_preread`: the console and webmail names go to an nginx `http` server on a loopback port that terminates TLS, and every other name is passed through untouched, with PROXY protocol, to the server's own HTTPS listener on loopback. The server then serves its own certificates for any domain, its TLSA records match, and TLS-ALPN-01 reaches it. Fix: - Write the nginx snippet that way: a `stream` block (`ssl_preread`, a `map` of the console and webmail names, default to the server's HTTPS listener, `proxy_protocol on`), the console and webmail `http` servers on a loopback port with `proxy_protocol` and `real_ip_header proxy_protocol`, and port 80 passing every name's ACME challenges to the server (not just the install-time list). - Set up the server side to match: an HTTPS listener on loopback that accepts PROXY protocol from 127.0.0.1 only. - Say in the file that it needs nginx's stream module (`libnginx-mod-stream` on Debian/Ubuntu) and that the `server` block for 443 goes inside `stream { }`. - Check the Caddy fragment for the same problems (plain Caddy can't route TLS by SNI without the layer4 plugin, so it may need a different answer, or a note). - Docs: "Behind your own web server" in the installer guide (inbuxa.org `docs-site/content/docs/install/installer.md`) should say what happens with domains added later and with TLSA. - e2e: add a second domain after install and check its `mta-sts.` name gets the server's certificate through the snippet.
jcoffey-dev added the bug
priority
p2
labels 2026-11-08 08:22:11 +00:00
jcoffey-dev self-assigned this 2026-11-08 08:22:11 +00:00
Author
Owner

Fixed in #49 and #51, released in installer v27.1-rc.6. Behind nginx, port 443 is now routed by name: nginx terminates the console and the webmail and passes the server's names through to its own HTTPS, so domains added later and the 443 TLSA records work. Other names on nginx's TLS port get 421. An existing install moves over when install is run again with --key.

Fixed in #49 and #51, released in installer v27.1-rc.6. Behind nginx, port 443 is now routed by name: nginx terminates the console and the webmail and passes the server's names through to its own HTTPS, so domains added later and the 443 TLSA records work. Other names on nginx's TLS port get 421. An existing install moves over when `install` is run again with `--key`.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: inbuxa/inbuxa-installer#48