--proxy snippets: nginx answers 421 for any other name on its TLS port #51
No files matched your search
@@ -58,6 +58,10 @@ CODE=$(via mail.$D -o /dev/null -w '%{http_code}' https://mail.$D/.well-known/jm
|
||||
case "$CODE" in 30*|200|401) ok "the mail server answers on https://mail.$D ($CODE)" ;; *) bad "https://mail.$D/.well-known/jmap answered $CODE" ;; esac
|
||||
via admin.$D https://admin.$D/ | grep -q "content=\"https://mail.$D\"" && ok "the console, pointed at https://mail.$D" || bad "the console is not served through nginx"
|
||||
via webmail.$D https://webmail.$D/api/health | grep -q '"ok":true' && ok "the webmail is healthy through nginx" || bad "the webmail is not healthy through nginx"
|
||||
# A browser reuses the webmail's connection for any name its certificate
|
||||
# covers: a request for the mail server that arrives that way is sent back.
|
||||
CODE=$(via webmail.$D -o /dev/null -w '%{http_code}' -H "Host: mail.$D" https://webmail.$D/.well-known/jmap)
|
||||
[ "$CODE" = 421 ] && ok "a request for mail.$D on the webmail's connection gets 421" || bad "a request for mail.$D on the webmail's connection answered $CODE"
|
||||
ADMIN_FP=$(openssl x509 -in /etc/ssl/inbuxa/admin.$D.fullchain.pem -noout -fingerprint -sha256)
|
||||
WEBMAIL_FP=$(openssl x509 -in /etc/ssl/inbuxa/webmail.$D.fullchain.pem -noout -fingerprint -sha256)
|
||||
[ "$(fp admin.$D)" = "$ADMIN_FP" ] && ok "the console is served with nginx's certificate" || bad "the console's certificate is not nginx's"
|
||||
|
||||
@@ -236,6 +236,7 @@ func TestProxySnippetsRouteByName(t *testing.T) {
|
||||
"listen 127.0.0.1:8444 ssl proxy_protocol;", "real_ip_header proxy_protocol;",
|
||||
"~^(autoconfig|autodiscover|mta-sts|ua-auto-config)\\.;",
|
||||
"location /.well-known/acme-challenge/",
|
||||
"listen 127.0.0.1:8444 ssl proxy_protocol default_server;", "ssl_reject_handshake on;", "return 421;",
|
||||
} {
|
||||
if !strings.Contains(string(nginx), want) {
|
||||
t.Errorf("nginx-inbuxa.conf lacks %q", want)
|
||||
@@ -246,7 +247,7 @@ func TestProxySnippetsRouteByName(t *testing.T) {
|
||||
t.Errorf("nginx-inbuxa.conf still has %q: the router holds 443 and the server's names are its own", bad)
|
||||
}
|
||||
}
|
||||
if strings.Count(string(nginx), "listen 127.0.0.1:8444") != 2 {
|
||||
if strings.Count(string(nginx), "listen 127.0.0.1:8444 ssl proxy_protocol;") != 2 {
|
||||
t.Errorf("the console and the webmail are not both behind the router:\n%s", nginx)
|
||||
}
|
||||
|
||||
@@ -277,6 +278,9 @@ func TestProxySnippetsWithoutRoutingStayAsTheyWere(t *testing.T) {
|
||||
t.Errorf("nginx-inbuxa.conf lacks %q", want)
|
||||
}
|
||||
}
|
||||
if strings.Contains(string(nginx), "return 421;") {
|
||||
t.Error("the fallback for the router's port is written without the router")
|
||||
}
|
||||
c, _ := render(t, s)
|
||||
if strings.Contains(c, ":443\"") {
|
||||
t.Errorf("the server's HTTPS is published without the router:\n%s", c)
|
||||
|
||||
@@ -173,3 +173,19 @@ server {
|
||||
}
|
||||
}
|
||||
{{- end}}
|
||||
{{- if .RoutesByName}}
|
||||
|
||||
# Any other name asked of {{.FrontTLSBind}}: 421, so the browser opens a new
|
||||
# connection for it. A browser reuses a connection for every name its
|
||||
# certificate covers, so with one certificate for the console's, the
|
||||
# webmail's and the mail server's names, a request for the mail server can
|
||||
# arrive here over the webmail's connection, without the router seeing its
|
||||
# name. Answered from here, it would get the console or the webmail. No
|
||||
# certificate: the router sends this port only the two names above, and a
|
||||
# handshake for any other is refused.
|
||||
server {
|
||||
listen {{.FrontTLSBind}} ssl proxy_protocol default_server;
|
||||
ssl_reject_handshake on;
|
||||
return 421;
|
||||
}
|
||||
{{- end}}
|
||||
Reference in new issue
Block a user