From f3078d047c69e85bb04784cd40c78b30979fe591 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Thu, 30 Apr 2015 21:11:26 -0700 Subject: [PATCH 1/3] Get bucketName from mux.Vars instead of heuristic code, resolves subdomain issues --- pkg/api/api_signature.go | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/pkg/api/api_signature.go b/pkg/api/api_signature.go index 53f7fda6a..e1f4cd235 100644 --- a/pkg/api/api_signature.go +++ b/pkg/api/api_signature.go @@ -24,13 +24,13 @@ import ( "errors" "fmt" "io" - "net" "net/http" "net/url" "sort" "strings" "time" + "github.com/gorilla/mux" "github.com/minio-io/minio/pkg/api/config" ) @@ -175,8 +175,8 @@ var subResList = []string{ // + // [ sub-resource, if present. For example "?acl", "?location", "?logging", or "?torrent"]; func writeCanonicalizedResource(buf *bytes.Buffer, req *http.Request) { - // Grab bucket name from hostname - bucket := bucketFromHostname(req) + vars := mux.Vars(req) + bucket := vars["bucket"] if bucket != "" { buf.WriteByte('/') buf.WriteString(bucket) @@ -203,23 +203,3 @@ func writeCanonicalizedResource(buf *bytes.Buffer, req *http.Request) { } } } - -// Convert subdomain http request into bucketname if possible -func bucketFromHostname(req *http.Request) string { - host, _, _ := net.SplitHostPort(req.Host) - // Verify incoming request if only IP with no bucket subdomain - if net.ParseIP(host) != nil { - return "" - } - if host == "" { - host = req.URL.Host - } - - // Grab the bucket from the incoming hostname - host = strings.TrimSpace(host) - hostParts := strings.Split(host, ".") - if len(hostParts) > 2 { - return hostParts[0] - } - return "" -} From bbc32d6ac01c4996959ca802addf86ea3619f143 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Thu, 30 Apr 2015 21:15:53 -0700 Subject: [PATCH 2/3] Disable domain based routing for now --- main.go | 14 +++++++------- pkg/api/api_router.go | 8 +++++--- pkg/server/httpserver/httpserver.go | 2 +- pkg/server/server.go | 5 +++-- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/main.go b/main.go index 837f12d1a..5e129f76b 100644 --- a/main.go +++ b/main.go @@ -93,11 +93,11 @@ EXAMPLES: } var flags = []cli.Flag{ - cli.StringFlag{ - Name: "domain", - Value: "", - Usage: "domain used for routing incoming API requests", - }, + // cli.StringFlag{ + // Name: "domain", + // Value: "", + // Usage: "domain used for routing incoming API requests", + // }, cli.StringFlag{ Name: "api-address", Value: ":9000", @@ -191,7 +191,7 @@ func getAPIServerConfig(c *cli.Context) httpserver.Config { } tls := (certFile != "" && keyFile != "") return httpserver.Config{ - Domain: c.GlobalString("domain"), + // Domain: c.GlobalString("domain"), Address: c.GlobalString("api-address"), TLS: tls, CertFile: certFile, @@ -201,7 +201,7 @@ func getAPIServerConfig(c *cli.Context) httpserver.Config { func getWebServerConfigFunc(c *cli.Context) server.StartServerFunc { config := httpserver.Config{ - Domain: c.GlobalString("domain"), + // Domain: c.GlobalString("domain"), Address: c.GlobalString("web-address"), TLS: false, CertFile: "", diff --git a/pkg/api/api_router.go b/pkg/api/api_router.go index 65ccd500c..2ab8721e8 100644 --- a/pkg/api/api_router.go +++ b/pkg/api/api_router.go @@ -47,6 +47,7 @@ func pathMux(api minioAPI, mux *router.Router) *router.Router { return mux } +/* // Domain based routing func domainMux(api minioAPI, mux *router.Router) *router.Router { mux.HandleFunc("/", @@ -63,15 +64,16 @@ func domainMux(api minioAPI, mux *router.Router) *router.Router { return mux } +*/ // Get proper router based on domain availability func getMux(api minioAPI, mux *router.Router) *router.Router { switch true { case api.domain == "": return pathMux(api, mux) - case api.domain != "": - s := mux.Host(api.domain).Subrouter() - return domainMux(api, s) + // case api.domain != "": + // s := mux.Host(api.domain).Subrouter() + // return domainMux(api, s) } return nil } diff --git a/pkg/server/httpserver/httpserver.go b/pkg/server/httpserver/httpserver.go index 8abe9de49..0570789cd 100644 --- a/pkg/server/httpserver/httpserver.go +++ b/pkg/server/httpserver/httpserver.go @@ -29,7 +29,7 @@ type Config struct { CertFile string KeyFile string Websocket bool // TODO - Domain string + // Domain string } // Server - http server related diff --git a/pkg/server/server.go b/pkg/server/server.go index 3efbbded8..008360ec6 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -41,7 +41,8 @@ type MemoryFactory struct { func (f MemoryFactory) GetStartServerFunc() StartServerFunc { return func() (chan<- string, <-chan error) { _, _, driver := memory.Start(f.MaxMemory, 1*time.Hour) - ctrl, status, _ := httpserver.Start(api.HTTPHandler(f.Domain, driver), f.Config) + //ctrl, status, _ := httpserver.Start(api.HTTPHandler(f.Domain, driver), f.Config) + ctrl, status, _ := httpserver.Start(api.HTTPHandler("", driver), f.Config) return ctrl, status } } @@ -69,7 +70,7 @@ type DonutFactory struct { func (f DonutFactory) GetStartServerFunc() StartServerFunc { return func() (chan<- string, <-chan error) { _, _, driver := donut.Start(f.Paths) - ctrl, status, _ := httpserver.Start(api.HTTPHandler(f.Domain, driver), f.Config) + ctrl, status, _ := httpserver.Start(api.HTTPHandler("", driver), f.Config) return ctrl, status } } From bbace9ac2e489976d60124dd29a3f325fa7dc326 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Thu, 30 Apr 2015 21:16:49 -0700 Subject: [PATCH 3/3] Make buildDate universal --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 5105b87fd..c654088ad 100644 --- a/Makefile +++ b/Makefile @@ -49,7 +49,7 @@ minio: pre-build build-all test-all install: minio @echo "Installing minio:" - @godep go install -a -ldflags "-X main.BuildDate `date '+%FT%T.%N%:z'`" github.com/minio-io/minio + @godep go install -a -ldflags "-X main.BuildDate `date --universal '+%FT%T.%N%:z'`" github.com/minio-io/minio save: restore @godep save ./...