From d90044b8478cbfea52f6df16ddea4e73662fcac7 Mon Sep 17 00:00:00 2001 From: Anis Elleuch Date: Wed, 9 Dec 2020 16:25:26 +0100 Subject: [PATCH] federation: Redirect Lifecycle PUT request by bucket name (#11062) The bucket forwarder handler considers MakeBucket to be always local but it mistakenly thinks that PUT bucket lifecycle to be a MakeBucket call. Fix the check of the MakeBucket call by ensuring that the query is empty in the PUT url. --- cmd/generic-handlers.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/generic-handlers.go b/cmd/generic-handlers.go index 9d2c6304e..167371b4a 100644 --- a/cmd/generic-handlers.go +++ b/cmd/generic-handlers.go @@ -634,7 +634,7 @@ func (f bucketForwardingHandler) ServeHTTP(w http.ResponseWriter, r *http.Reques // For browser requests, when federation is setup we need to // specifically handle download and upload for browser requests. - if guessIsBrowserReq(r) && globalDNSConfig != nil && len(globalDomainNames) > 0 { + if globalDNSConfig != nil && len(globalDomainNames) > 0 && guessIsBrowserReq(r) { var bucket, _ string switch r.Method { case http.MethodPut: @@ -689,7 +689,7 @@ func (f bucketForwardingHandler) ServeHTTP(w http.ResponseWriter, r *http.Reques } // MakeBucket requests should be handled at current endpoint - if r.Method == http.MethodPut && bucket != "" && object == "" { + if r.Method == http.MethodPut && bucket != "" && object == "" && r.URL.RawQuery == "" { f.handler.ServeHTTP(w, r) return }