From 05b5f12f2e13d13e5ea3b983defead47f8b16a16 Mon Sep 17 00:00:00 2001 From: Konstantin Lebedev Date: Wed, 21 Oct 2020 20:48:51 +0500 Subject: [PATCH] multiplate DomainNames through comma --- weed/s3api/s3api_server.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/weed/s3api/s3api_server.go b/weed/s3api/s3api_server.go index 1ab80c3ee..b1e1cfe80 100644 --- a/weed/s3api/s3api_server.go +++ b/weed/s3api/s3api_server.go @@ -3,6 +3,7 @@ package s3api import ( "fmt" "net/http" + "strings" "github.com/gorilla/mux" "google.golang.org/grpc" @@ -39,10 +40,13 @@ func (s3a *S3ApiServer) registerRouter(router *mux.Router) { apiRouter := router.PathPrefix("/").Subrouter() var routers []*mux.Router if s3a.option.DomainName != "" { - routers = append(routers, apiRouter.Host( - fmt.Sprintf("%s.%s:%d", "{bucket:.+}", s3a.option.DomainName, s3a.option.Port)).Subrouter()) - routers = append(routers, apiRouter.Host( - fmt.Sprintf("%s.%s", "{bucket:.+}", s3a.option.DomainName)).Subrouter()) + domainNames := strings.Split(s3a.option.DomainName, ",") + for _, domainName := range domainNames { + routers = append(routers, apiRouter.Host( + fmt.Sprintf("%s.%s:%d", "{bucket:.+}", domainName, s3a.option.Port)).Subrouter()) + routers = append(routers, apiRouter.Host( + fmt.Sprintf("%s.%s", "{bucket:.+}", domainName)).Subrouter()) + } } routers = append(routers, apiRouter.PathPrefix("/{bucket}").Subrouter())