diff --git a/plugin/forward/setup.go b/plugin/forward/setup.go index e07bdef3e..3e07bce29 100644 --- a/plugin/forward/setup.go +++ b/plugin/forward/setup.go @@ -242,7 +242,8 @@ func parseStanza(c *caddy.Controller) (*Forward, error) { } // Only set this for proxies that need it. - if transports[i] == transport.TLS || transports[i] == transport.QUIC { + if transports[i] == transport.TLS || transports[i] == transport.HTTPS || transports[i] == transport.QUIC { + f.proxies[i].SetDOHHost(f.tlsConfig.ServerName) if tlsConfig, ok := perServerNameTlsConfig[tlsServerNames[i]]; ok { f.proxies[i].SetTLSConfig(tlsConfig) } else { diff --git a/plugin/forward/setup_test.go b/plugin/forward/setup_test.go index ec645ffdd..0ea905c4e 100644 --- a/plugin/forward/setup_test.go +++ b/plugin/forward/setup_test.go @@ -960,8 +960,17 @@ func TestSetupDOHHealthcheckTLSConfig(t *testing.T) { t.Fatal(err) } - got := fs[0]. - proxies[0]. + p := fs[0].proxies[0] + + if gothost := p.DoHHost(); gothost != "dns.example" { + t.Fatalf( + "Expected dohHost %q, got %q", + "dns.example", + gothost, + ) + } + + got := p. GetHealthchecker(). GetTLSConfig()