The nginx file terminated TLS for the server's names with a certificate the operator supplied, for the names known at install time only. A domain added later got the wrong certificate on 443, its HTTP-01 challenges weren't forwarded on port 80, and the server's _443._tcp TLSA records described a certificate nobody was served. nginx now routes 443 by name, in nginx-inbuxa-stream.conf (stream, ssl_preread). The console and the webmail go to nginx's own TLS on 127.0.0.1:8444; every other name goes, untouched and with the PROXY protocol header, to the server's own HTTPS listener on 127.0.0.1:8443. That listener is fitted by the installer (jmap.PassThroughListener): bound on loopback on the host, or kept on the container's 443 and published on 127.0.0.1:8443, and taking PROXY only from where nginx connects. Port 80 also passes the challenges of the four service names of any domain. An install from before keeps its layout, since a new file in front of an unfitted server would break its names at the next reload. Running install again with --key fits the listener and moves it over; the install record notes it (passThrough). A move between shapes fits it again. Caddy can't route by name without a plugin, so its fragment says what that means for domains added later and TLSA.
74 lines
2.1 KiB
Cheetah
74 lines
2.1 KiB
Cheetah
# Written by the inbuxa installer {{.Version}} for {{.Domain}}.
|
|
#
|
|
# For the web server already on this machine: Caddy. Import it from your
|
|
# Caddyfile (`import {{.Dir}}/proxy/Caddyfile.fragment`) and reload. It has no
|
|
# global options block, so it can sit beside your own sites. The installer
|
|
# loads nothing and restarts nothing.
|
|
#
|
|
# Everything is passed to loopback: 8081 the mail server, 8082 the console,
|
|
# 8080 the webmail. Caddy gets certificates for the console and the webmail
|
|
# itself.
|
|
{{- if .ServesServer}}
|
|
|
|
# The mail server's names. Caddy uses TLS-ALPN-01 for them and leaves HTTP-01
|
|
# on port 80 to the mail server, which needs a certificate of its own for
|
|
# IMAP and SMTP: so neither answers the other's challenge.
|
|
#
|
|
# Caddy can't pass TLS through by name without the layer4 plugin, so it
|
|
# terminates these names itself, with certificates of its own. Two things
|
|
# follow. A domain added to the server later is not here: add its names to
|
|
# both blocks below. And with TLSA records published, the server's _443._tcp
|
|
# ones describe its own certificate, not Caddy's, so they don't match on 443
|
|
# (the mail ports are unaffected). The nginx configuration beside this passes
|
|
# the server's names through to the server instead.
|
|
{{join .ServerNames ", "}} {
|
|
tls {
|
|
issuer acme {
|
|
email {{.Email}}
|
|
disable_http_challenge
|
|
}
|
|
}
|
|
reverse_proxy 127.0.0.1:8081 {
|
|
flush_interval -1
|
|
}
|
|
}
|
|
|
|
{{range $i, $n := .ServerNames}}{{if $i}}, {{end}}http://{{$n}}{{end}} {
|
|
handle /.well-known/acme-challenge/* {
|
|
reverse_proxy 127.0.0.1:8081
|
|
}
|
|
handle {
|
|
redir https://{host}{uri} 308
|
|
}
|
|
}
|
|
{{- end}}
|
|
{{- if .Console}}
|
|
|
|
{{.ConsoleHost}} {
|
|
encode zstd gzip
|
|
reverse_proxy 127.0.0.1:8082
|
|
}
|
|
{{- end}}
|
|
{{- if .ConsoleFiles}}
|
|
|
|
# The console, installed on this machine as files.
|
|
{{.ConsoleHost}} {
|
|
encode zstd gzip
|
|
root * {{.ConsoleFiles}}
|
|
try_files {path} /index.html
|
|
header /assets/* Cache-Control "public, max-age=31536000, immutable"
|
|
@page not path /assets/*
|
|
header @page Cache-Control "no-cache"
|
|
file_server
|
|
}
|
|
{{- end}}
|
|
{{- if .ServesWebmail}}
|
|
|
|
{{.WebmailHost}} {
|
|
encode zstd gzip
|
|
reverse_proxy 127.0.0.1:8080 {
|
|
flush_interval -1
|
|
}
|
|
}
|
|
{{- end}}
|