diff --git a/cmd/tailscale/cli/serve_v2.go b/cmd/tailscale/cli/serve_v2.go index 2f1c4eda8..d86bd8003 100644 --- a/cmd/tailscale/cli/serve_v2.go +++ b/cmd/tailscale/cli/serve_v2.go @@ -932,7 +932,7 @@ func (e *serveEnv) removeWebServe(sc *ipn.ServeConfig, st *ipnstate.Status, dnsN if svc == nil { return errors.New("service does not exist") } - hostName = svcName.WithoutPrefix() + "." + st.CurrentTailnet.MagicDNSSuffix + hostName = strings.Join([]string{svcName.WithoutPrefix(), st.CurrentTailnet.MagicDNSSuffix}, ".") webServeMap = svc.Web } diff --git a/ipn/serve.go b/ipn/serve.go index 5f42dd8e1..d33372940 100644 --- a/ipn/serve.go +++ b/ipn/serve.go @@ -348,7 +348,7 @@ func (sc *ServeConfig) SetWebHandler(st *ipnstate.Status, handler *HTTPHandler, webServerMap := &sc.Web hostName := host if svcName, ok := tailcfg.AsServiceName(host); ok { - hostName = svcName.WithoutPrefix() + "." + st.CurrentTailnet.MagicDNSSuffix + hostName = strings.Join([]string{svcName.WithoutPrefix(), st.CurrentTailnet.MagicDNSSuffix}, ".") if _, ok := sc.Services[svcName]; !ok { mak.Set(&sc.Services, svcName, new(ServiceConfig)) } @@ -458,8 +458,8 @@ func (sc *ServeConfig) RemoveWebHandler(host string, port uint16, mounts []strin // RemoveServiceWebHandler deletes the web handlers at all of the given mount points // for the provided host and port in the serve config for the given service. func (sc *ServeConfig) RemoveServiceWebHandler(st *ipnstate.Status, svcName tailcfg.ServiceName, port uint16, mounts []string) { - dnsNameForService := svcName.WithoutPrefix() + "." + st.CurrentTailnet.MagicDNSSuffix - hp := HostPort(net.JoinHostPort(dnsNameForService, strconv.Itoa(int(port)))) + hostName := strings.Join([]string{svcName.WithoutPrefix(), st.CurrentTailnet.MagicDNSSuffix}, ".") + hp := HostPort(net.JoinHostPort(hostName, strconv.Itoa(int(port)))) svc, ok := sc.Services[svcName] if !ok || svc == nil {