diff --git a/go.mod b/go.mod index 67d05c67d..fbee02edd 100644 --- a/go.mod +++ b/go.mod @@ -15,6 +15,7 @@ require ( github.com/go-openapi/validate v0.20.2 github.com/gorilla/websocket v1.4.2 github.com/jessevdk/go-flags v1.4.0 + github.com/klauspost/compress v1.13.6 // indirect github.com/minio/cli v1.22.0 github.com/minio/direct-csi v1.3.5-0.20210601185811-f7776f7961bf github.com/minio/kes v0.11.0 diff --git a/go.sum b/go.sum index 070d19496..a5db2abb2 100644 --- a/go.sum +++ b/go.sum @@ -764,6 +764,8 @@ github.com/klauspost/compress v1.4.1/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0 github.com/klauspost/compress v1.9.5/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/compress v1.12.2 h1:2KCfW3I9M7nSc5wOqXAlW2v2U6v+w6cbjvbfp+OykW8= github.com/klauspost/compress v1.12.2/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= +github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc= +github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/klauspost/cpuid v0.0.0-20180405133222-e7e905edc00e/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/klauspost/cpuid v1.2.0/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/klauspost/cpuid v1.2.3/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= diff --git a/operatorapi/configure_operator.go b/operatorapi/configure_operator.go index 5c165d211..365aeb954 100644 --- a/operatorapi/configure_operator.go +++ b/operatorapi/configure_operator.go @@ -24,6 +24,8 @@ import ( "net/http" "strings" + "github.com/klauspost/compress/gzhttp" + "github.com/minio/console/restapi" "github.com/unrolled/secure" @@ -155,7 +157,7 @@ func proxyMiddleware(next http.Handler) http.Handler { func setupGlobalMiddleware(handler http.Handler) http.Handler { // handle cookie or authorization header for session next := AuthenticationMiddleware(handler) - // serve static files + // proxy requests next = proxyMiddleware(next) // serve static files next = restapi.FileServerMiddleware(next) @@ -185,5 +187,6 @@ func setupGlobalMiddleware(handler http.Handler) http.Handler { IsDevelopment: false, } secureMiddleware := secure.New(secureOptions) - return secureMiddleware.Handler(next) + next = secureMiddleware.Handler(next) + return gzhttp.GzipHandler(next) } diff --git a/restapi/configure_console.go b/restapi/configure_console.go index b5adda1b4..b33ef6afc 100644 --- a/restapi/configure_console.go +++ b/restapi/configure_console.go @@ -31,6 +31,8 @@ import ( "strings" "time" + "github.com/klauspost/compress/gzhttp" + portal_ui "github.com/minio/console/portal-ui" "github.com/minio/pkg/mimedb" @@ -186,7 +188,9 @@ func setupGlobalMiddleware(handler http.Handler) http.Handler { IsDevelopment: false, } secureMiddleware := secure.New(secureOptions) - return RejectS3Middleware(secureMiddleware.Handler(next)) + next = secureMiddleware.Handler(next) + gnext := gzhttp.GzipHandler(next) + return RejectS3Middleware(gnext) } // RejectS3Middleware will reject requests that have AWS S3 specific headers.