|
|
@ -109,9 +109,10 @@ func (ch *CaddyHugo) ServeNewContent(w http.ResponseWriter, r *http.Request) (in |
|
|
|
|
|
|
|
|
|
|
|
func (ch *CaddyHugo) Middleware(c *caddy.Controller) httpserver.Middleware { |
|
|
|
func (ch *CaddyHugo) Middleware(c *caddy.Controller) httpserver.Middleware { |
|
|
|
return func(next httpserver.Handler) httpserver.Handler { |
|
|
|
return func(next httpserver.Handler) httpserver.Handler { |
|
|
|
host := net.JoinHostPort(ch.Site.Addr.Host, ch.Site.Addr.Port) |
|
|
|
host := ch.Site.Addr.Host |
|
|
|
|
|
|
|
hostport := net.JoinHostPort(ch.Site.Addr.Host, ch.Site.Addr.Port) |
|
|
|
return httpserver.HandlerFunc(func(w http.ResponseWriter, r *http.Request) (int, error) { |
|
|
|
return httpserver.HandlerFunc(func(w http.ResponseWriter, r *http.Request) (int, error) { |
|
|
|
if r.Host != host { |
|
|
|
if r.Host != host && r.Host != hostport { |
|
|
|
return next.ServeHTTP(w, r) |
|
|
|
return next.ServeHTTP(w, r) |
|
|
|
} |
|
|
|
} |
|
|
|
return ch.ServeHTTPWithNext(next, w, r) |
|
|
|
return ch.ServeHTTPWithNext(next, w, r) |
|
|
@ -125,8 +126,9 @@ func (ch *CaddyHugo) Auth(r *http.Request) bool { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (ch *CaddyHugo) Match(r *http.Request) bool { |
|
|
|
func (ch *CaddyHugo) Match(r *http.Request) bool { |
|
|
|
host := net.JoinHostPort(ch.Site.Addr.Host, ch.Site.Addr.Port) |
|
|
|
host := ch.Site.Addr.Host |
|
|
|
if r.Host != host { |
|
|
|
hostport := net.JoinHostPort(ch.Site.Addr.Host, ch.Site.Addr.Port) |
|
|
|
|
|
|
|
if r.Host != host && r.Host != hostport { |
|
|
|
return false |
|
|
|
return false |
|
|
|
} |
|
|
|
} |
|
|
|
if strings.HasPrefix(r.URL.Path, "/media/") { |
|
|
|
if strings.HasPrefix(r.URL.Path, "/media/") { |
|
|
|