diff --git a/cmd/generic-handlers.go b/cmd/generic-handlers.go index 583d7f4eb..fa4ba1666 100644 --- a/cmd/generic-handlers.go +++ b/cmd/generic-handlers.go @@ -371,7 +371,8 @@ func setRequestValidityHandler(h http.Handler) http.Handler { // is obtained from centralized etcd configuration service. func setBucketForwardingHandler(h http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - if guessIsHealthCheckReq(r) || guessIsMetricsReq(r) || + if globalDNSConfig == nil || !globalBucketFederation || + guessIsHealthCheckReq(r) || guessIsMetricsReq(r) || guessIsRPCReq(r) || guessIsLoginSTSReq(r) || isAdminReq(r) { h.ServeHTTP(w, r) return diff --git a/cmd/routers.go b/cmd/routers.go index 62a7b869f..c5f5de37c 100644 --- a/cmd/routers.go +++ b/cmd/routers.go @@ -58,6 +58,8 @@ var globalHandlers = []mux.MiddlewareFunc{ setRequestValidityHandler, // set x-amz-request-id header. addCustomHeaders, + // Add bucket forwarding handler + setBucketForwardingHandler, // Add new handlers here. } @@ -87,10 +89,6 @@ func configureServerHandler(endpointServerPools EndpointServerPools) (http.Handl // Add API router registerAPIRouter(router) - // Enable bucket forwarding handler only if bucket federation is enabled. - if globalDNSConfig != nil && globalBucketFederation { - globalHandlers = append(globalHandlers, setBucketForwardingHandler) - } router.Use(globalHandlers...) return router, nil