diff options
| author | Chris Lu <chris.lu@gmail.com> | 2018-07-22 21:28:54 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2018-07-22 21:28:54 -0700 |
| commit | 7f32eb1e25ab22f1276d60d15d81b6bf84a79d3c (patch) | |
| tree | 77b841053d98be291678911f77899d1feeedf557 /weed/command | |
| parent | c133e72f623fc12b04fe3a34aa2a9d0da53dc9e0 (diff) | |
| download | seaweedfs-7f32eb1e25ab22f1276d60d15d81b6bf84a79d3c.tar.xz seaweedfs-7f32eb1e25ab22f1276d60d15d81b6bf84a79d3c.zip | |
s3 add https support
Diffstat (limited to 'weed/command')
| -rw-r--r-- | weed/command/s3.go | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/weed/command/s3.go b/weed/command/s3.go index 2d58d93a9..16a9490ff 100644 --- a/weed/command/s3.go +++ b/weed/command/s3.go @@ -21,6 +21,8 @@ type S3Options struct { filerBucketsPath *string port *int domainName *string + tlsPrivateKey *string + tlsCertificate *string } func init() { @@ -30,6 +32,8 @@ func init() { s3options.filerBucketsPath = cmdS3.Flag.String("filer.dir.buckets", "/buckets", "folder on filer to store all buckets") s3options.port = cmdS3.Flag.Int("port", 8333, "s3options server http listen port") s3options.domainName = cmdS3.Flag.String("domainName", "", "suffix of the host name, {bucket}.{domainName}") + s3options.tlsPrivateKey = cmdS3.Flag.String("key.file", "", "path to the TLS private key file") + s3options.tlsCertificate = cmdS3.Flag.String("cert.file", "", "path to the TLS certificate file") } var cmdS3 = &Command{ @@ -60,15 +64,24 @@ func runS3(cmd *Command, args []string) bool { glog.Fatalf("S3 API Server startup error: %v", s3ApiServer_err) } - glog.V(0).Infof("Start Seaweed S3 API Server %s at port %d", util.VERSION, *s3options.port) - s3ApiListener, e := util.NewListener(fmt.Sprintf(":%d", *s3options.port), time.Duration(10)*time.Second) - if e != nil { - glog.Fatalf("S3 API Server listener error: %v", e) + httpS := &http.Server{Handler: router} + + listenAddress := fmt.Sprintf(":%d", *s3options.port) + s3ApiListener, err := util.NewListener(listenAddress, time.Duration(10)*time.Second) + if err != nil { + glog.Fatalf("S3 API Server listener on %s error: %v", listenAddress, err) } - httpS := &http.Server{Handler: router} - if err := httpS.Serve(s3ApiListener); err != nil { - glog.Fatalf("S3 API Server Fail to serve: %v", e) + if *s3options.tlsPrivateKey != "" { + if err = httpS.ServeTLS(s3ApiListener, *s3options.tlsCertificate, *s3options.tlsPrivateKey); err != nil { + glog.Fatalf("S3 API Server Fail to serve: %v", err) + } + glog.V(0).Infof("Start Seaweed S3 API Server %s at https port %d", util.VERSION, *s3options.port) + } else { + if err = httpS.Serve(s3ApiListener); err != nil { + glog.Fatalf("S3 API Server Fail to serve: %v", err) + } + glog.V(0).Infof("Start Seaweed S3 API Server %s at http port %d", util.VERSION, *s3options.port) } return true |
