Fix: Handle regression caused by gorilla mux v1.7.0 (#7625)

PR #7595 fixed part of the regression, but did not handle the
scenario, where in docker, the internal port is different from
the port on the host.

This PR modifies the regular expression such that all the
scenarios are handled.

Fixes #7619
This commit is contained in:
kannappanr 2019-05-07 10:36:00 -07:00 committed by Harshavardhana
parent 08b9244c48
commit c422f7f412

View File

@ -17,7 +17,6 @@
package cmd
import (
"net"
"net/http"
"github.com/gorilla/mux"
@ -46,13 +45,8 @@ func registerAPIRouter(router *mux.Router, encryptionEnabled bool) {
apiRouter := router.PathPrefix("/").Subrouter()
var routers []*mux.Router
for _, domainName := range globalDomainNames {
var hostPort string
if globalMinioPort != "443" && globalMinioPort != "80" {
hostPort = net.JoinHostPort(domainName, globalMinioPort)
} else {
hostPort = domainName
}
routers = append(routers, apiRouter.Host("{bucket:.+}."+hostPort).Subrouter())
routers = append(routers, apiRouter.Host("{bucket:.+}."+domainName).Subrouter())
routers = append(routers, apiRouter.Host("{bucket:.+}."+domainName+":{port:.*}").Subrouter())
}
routers = append(routers, apiRouter.PathPrefix("/{bucket}").Subrouter())