diff --git a/internal/outpost/proxyv2/handlers.go b/internal/outpost/proxyv2/handlers.go index f54170f5b..95045cc9c 100644 --- a/internal/outpost/proxyv2/handlers.go +++ b/internal/outpost/proxyv2/handlers.go @@ -31,7 +31,7 @@ func (ps *ProxyServer) HandlePing(rw http.ResponseWriter, r *http.Request) { func (ps *ProxyServer) HandleStatic(rw http.ResponseWriter, r *http.Request) { staticFs := http.FileServer(http.FS(staticWeb.StaticDist)) before := time.Now() - http.StripPrefix("/akprox/static", staticFs).ServeHTTP(rw, r) + web.DisableIndex(http.StripPrefix("/akprox/static", staticFs)).ServeHTTP(rw, r) after := time.Since(before) metrics.Requests.With(prometheus.Labels{ "outpost_name": ps.akAPI.Outpost.Name, @@ -54,7 +54,7 @@ func (ps *ProxyServer) Handle(rw http.ResponseWriter, r *http.Request) { if !ok { // If we only have one handler, host name switching doesn't matter if len(ps.apps) == 1 { - ps.log.WithField("host", host).Warning("passing to single app mux") + ps.log.WithField("host", host).Trace("passing to single app mux") for k := range ps.apps { ps.apps[k].ServeHTTP(rw, r) return diff --git a/internal/web/static_utils.go b/internal/utils/web/static.go similarity index 81% rename from internal/web/static_utils.go rename to internal/utils/web/static.go index 06739a90a..4f6c2ee85 100644 --- a/internal/web/static_utils.go +++ b/internal/utils/web/static.go @@ -5,7 +5,7 @@ import ( "strings" ) -func disableIndex(next http.Handler) http.Handler { +func DisableIndex(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if strings.HasSuffix(r.URL.Path, "/") { http.NotFound(w, r) diff --git a/internal/web/static.go b/internal/web/static.go index 6d81e7332..0cb034696 100644 --- a/internal/web/static.go +++ b/internal/web/static.go @@ -7,6 +7,7 @@ import ( "github.com/gorilla/mux" "goauthentik.io/internal/config" "goauthentik.io/internal/constants" + "goauthentik.io/internal/utils/web" staticWeb "goauthentik.io/web" staticDocs "goauthentik.io/website" ) @@ -14,7 +15,7 @@ import ( func (ws *WebServer) configureStatic() { statRouter := ws.lh.NewRoute().Subrouter() indexLessRouter := statRouter.NewRoute().Subrouter() - indexLessRouter.Use(disableIndex) + indexLessRouter.Use(web.DisableIndex) // Media files, always local fs := http.FileServer(http.Dir(config.G.Paths.Media)) var distHandler http.Handler @@ -42,7 +43,7 @@ func (ws *WebServer) configureStatic() { indexLessRouter.PathPrefix("/if/flow/{flow_slug}/assets").HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) - disableIndex(http.StripPrefix(fmt.Sprintf("/if/flow/%s", vars["flow_slug"]), distFs)).ServeHTTP(rw, r) + web.DisableIndex(http.StripPrefix(fmt.Sprintf("/if/flow/%s", vars["flow_slug"]), distFs)).ServeHTTP(rw, r) }) indexLessRouter.PathPrefix("/if/admin/assets").Handler(http.StripPrefix("/if/admin", distFs)) indexLessRouter.PathPrefix("/if/user/assets").Handler(http.StripPrefix("/if/user", distFs))