diff --git a/caddyhttp/httpserver/plugin.go b/caddyhttp/httpserver/plugin.go index 7066f0dff..9be67c1e4 100644 --- a/caddyhttp/httpserver/plugin.go +++ b/caddyhttp/httpserver/plugin.go @@ -206,11 +206,11 @@ func groupSiteConfigsByListenAddr(configs []*SiteConfig) (map[string][]*SiteConf groups := make(map[string][]*SiteConfig) for _, conf := range configs { - if caddy.IsLoopback(conf.Addr.Host) && conf.ListenHost == "" { - // special case: one would not expect a site served - // at loopback to be connected to from the outside. - conf.ListenHost = conf.Addr.Host - } + // We would add a special case here so that localhost addresses + // bind to 127.0.0.1 if conf.ListenHost is not already set, which + // would prevent outsiders from even connecting; but that was problematic: + // https://forum.caddyserver.com/t/wildcard-virtual-domains-with-wildcard-roots/221/5?u=matt + if conf.Addr.Port == "" { conf.Addr.Port = Port } diff --git a/caddyhttp/httpserver/vhosttrie.go b/caddyhttp/httpserver/vhosttrie.go index 558255783..ac04fd8a3 100644 --- a/caddyhttp/httpserver/vhosttrie.go +++ b/caddyhttp/httpserver/vhosttrie.go @@ -11,8 +11,8 @@ import ( // by longest matching path. type vhostTrie struct { edges map[string]*vhostTrie - site *SiteConfig // also known as a virtual host - path string // the path portion of the key for this node + site *SiteConfig // site to match on this node; also known as a virtual host + path string // the path portion of the key for the associated site } // newVHostTrie returns a new vhostTrie. @@ -137,3 +137,24 @@ func (t *vhostTrie) splitHostPath(key string) (host, path string) { } return } + +// String returns a list of all the entries in t; assumes that +// t is a root node. +func (t *vhostTrie) String() string { + var s string + for host, edge := range t.edges { + s += edge.str(host) + } + return s +} + +func (t *vhostTrie) str(prefix string) string { + var s string + for key, edge := range t.edges { + if edge.site != nil { + s += prefix + key + "\n" + } + s += edge.str(prefix + key) + } + return s +}