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.
57 lines
2.1 KiB
Cheetah
57 lines
2.1 KiB
Cheetah
# Written by the inbuxa installer {{.Version}} for {{.Domain}}.
|
|
#
|
|
# nginx's name router for port 443, which nginx-inbuxa.conf beside it needs.
|
|
# It goes outside the http block, so include it from the top of
|
|
# /etc/nginx/nginx.conf, next to `events`, not from conf.d/:
|
|
#
|
|
# include {{.Dir}}/proxy/nginx-inbuxa-stream.conf;
|
|
#
|
|
# It needs nginx's stream module: libnginx-mod-stream on Debian and Ubuntu,
|
|
# nginx-mod-stream on the Red Hat family. Check with `nginx -t` and reload.
|
|
# The installer loads nothing and restarts nothing.
|
|
#
|
|
# It reads the name a client asks for (SNI) and decrypts nothing itself:
|
|
{{- if or .Console .ConsoleFiles .ServesWebmail}}
|
|
# - the console and the webmail go to nginx's own TLS on {{.FrontTLSBind}}
|
|
# (in nginx-inbuxa.conf), with your certificates;
|
|
{{- end}}
|
|
# - every other name goes to the mail server's own HTTPS on
|
|
# {{.PassThroughBind}}, untouched. It has certificates of its own for
|
|
# each of its domains, a domain added later included, and its _443._tcp
|
|
# TLSA records match what it serves.
|
|
# Both are sent the PROXY protocol header first, so they see the client's own
|
|
# address. The server takes that header only from where nginx connects, and
|
|
# refuses a connection from there without it.
|
|
#
|
|
# nginx allows one stream block. If you have one already, move the map, the
|
|
# two upstreams and the server into it. Any site of your own that listens on
|
|
# 443 in the http block has to move off it, to {{.FrontTLSBind}} like the
|
|
# console, with its name added to the map: otherwise this port is taken
|
|
# twice, and its name would be sent to the mail server.
|
|
stream {
|
|
map $ssl_preread_server_name $inbuxa_upstream {
|
|
{{- if or .Console .ConsoleFiles}}
|
|
{{.ConsoleHost}} inbuxa_front;
|
|
{{- end}}
|
|
{{- if .ServesWebmail}}
|
|
{{.WebmailHost}} inbuxa_front;
|
|
{{- end}}
|
|
default inbuxa_server;
|
|
}
|
|
|
|
upstream inbuxa_server {
|
|
server {{.PassThroughBind}};
|
|
}
|
|
upstream inbuxa_front {
|
|
server {{.FrontTLSBind}};
|
|
}
|
|
|
|
server {
|
|
listen 443;
|
|
listen [::]:443;
|
|
ssl_preread on;
|
|
proxy_pass $inbuxa_upstream;
|
|
proxy_protocol on;
|
|
}
|
|
}
|