diff --git a/caddy/setup/browse.go b/caddy/setup/browse.go index 28cb2582b..4d3eaf819 100644 --- a/caddy/setup/browse.go +++ b/caddy/setup/browse.go @@ -3,6 +3,7 @@ package setup import ( "fmt" "io/ioutil" + "net/http" "text/template" "github.com/mholt/caddy/middleware" @@ -17,7 +18,6 @@ func Browse(c *Controller) (middleware.Middleware, error) { } browse := browse.Browse{ - Root: c.Root, Configs: configs, IgnoreIndexes: false, } @@ -50,6 +50,16 @@ func browseParse(c *Controller) ([]browse.Config, error) { } else { bc.PathScope = "/" } + bc.Root = http.Dir(c.Root) + theRoot, err := bc.Root.Open("/") // catch a missing path early + if err != nil { + return configs, err + } + defer theRoot.Close() + _, err = theRoot.Readdir(-1) + if err != nil { + return configs, err + } // Second argument would be the template file to use var tplText string @@ -85,7 +95,6 @@ const defaultTemplate = `