aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWeihao Jiang <weihau.chiang@gmail.com>2025-03-18 14:01:26 +0800
committerGitHub <noreply@github.com>2025-03-17 23:01:26 -0700
commit75ef3245334f12e0b3b420ba29aeea091b7d9afa (patch)
tree701e218df2762f489c9e2e275534f3177eba6c00
parent5ab04e1bafc24b6f895d63ff9a2db426f3d7ef27 (diff)
downloadseaweedfs-75ef3245334f12e0b3b420ba29aeea091b7d9afa.tar.xz
seaweedfs-75ef3245334f12e0b3b420ba29aeea091b7d9afa.zip
Allow standalone webdav server to bind specific address (#6403)
* Allow standalone webdav to bind specific address * Rename bindIp to ipBind * Bind embedded webdav IP to its parent
-rw-r--r--weed/command/filer.go1
-rw-r--r--weed/command/server.go1
-rw-r--r--weed/command/webdav.go11
3 files changed, 9 insertions, 4 deletions
diff --git a/weed/command/filer.go b/weed/command/filer.go
index b7f67ea3b..d763c7f3c 100644
--- a/weed/command/filer.go
+++ b/weed/command/filer.go
@@ -209,6 +209,7 @@ func runFiler(cmd *Command, args []string) bool {
if *filerStartWebDav {
filerWebDavOptions.filer = &filerAddress
+ filerWebDavOptions.ipBind = f.bindIp
if *filerWebDavOptions.disk == "" {
filerWebDavOptions.disk = f.diskType
diff --git a/weed/command/server.go b/weed/command/server.go
index 13d06a56b..e5265ecdc 100644
--- a/weed/command/server.go
+++ b/weed/command/server.go
@@ -221,6 +221,7 @@ func runServer(cmd *Command, args []string) bool {
s3Options.bindIp = serverBindIp
iamOptions.ip = serverBindIp
iamOptions.masters = masterOptions.peers
+ webdavOptions.ipBind = serverBindIp
serverOptions.v.ip = serverIp
serverOptions.v.bindIp = serverBindIp
serverOptions.v.masters = pb.ServerAddresses(*masterOptions.peers).ToAddresses()
diff --git a/weed/command/webdav.go b/weed/command/webdav.go
index 1d1a43eda..02798b9b6 100644
--- a/weed/command/webdav.go
+++ b/weed/command/webdav.go
@@ -23,6 +23,7 @@ var (
type WebDavOption struct {
filer *string
+ ipBind *string
filerRootPath *string
port *int
collection *string
@@ -38,6 +39,7 @@ type WebDavOption struct {
func init() {
cmdWebDav.Run = runWebDav // break init cycle
webDavStandaloneOptions.filer = cmdWebDav.Flag.String("filer", "localhost:8888", "filer server address")
+ webDavStandaloneOptions.ipBind = cmdWebDav.Flag.String("ip.bind", "", "ip address to bind to. Default listen to all.")
webDavStandaloneOptions.port = cmdWebDav.Flag.Int("port", 7333, "webdav server http listen port")
webDavStandaloneOptions.collection = cmdWebDav.Flag.String("collection", "", "collection to create the files")
webDavStandaloneOptions.replication = cmdWebDav.Flag.String("replication", "", "replication to create the files")
@@ -62,7 +64,8 @@ func runWebDav(cmd *Command, args []string) bool {
util.LoadSecurityConfiguration()
- glog.V(0).Infof("Starting Seaweed WebDav Server %s at https port %d", util.Version(), *webDavStandaloneOptions.port)
+ listenAddress := fmt.Sprintf("%s:%d", *webDavStandaloneOptions.ipBind, *webDavStandaloneOptions.port)
+ glog.V(0).Infof("Starting Seaweed WebDav Server %s at %s", util.Version(), listenAddress)
return webDavStandaloneOptions.startWebDav()
@@ -126,19 +129,19 @@ func (wo *WebDavOption) startWebDav() bool {
httpS := &http.Server{Handler: ws.Handler}
- listenAddress := fmt.Sprintf(":%d", *wo.port)
+ listenAddress := fmt.Sprintf("%s:%d", *wo.ipBind, *wo.port)
webDavListener, err := util.NewListener(listenAddress, time.Duration(10)*time.Second)
if err != nil {
glog.Fatalf("WebDav Server listener on %s error: %v", listenAddress, err)
}
if *wo.tlsPrivateKey != "" {
- glog.V(0).Infof("Start Seaweed WebDav Server %s at https port %d", util.Version(), *wo.port)
+ glog.V(0).Infof("Start Seaweed WebDav Server %s at https %s", util.Version(), listenAddress)
if err = httpS.ServeTLS(webDavListener, *wo.tlsCertificate, *wo.tlsPrivateKey); err != nil {
glog.Fatalf("WebDav Server Fail to serve: %v", err)
}
} else {
- glog.V(0).Infof("Start Seaweed WebDav Server %s at http port %d", util.Version(), *wo.port)
+ glog.V(0).Infof("Start Seaweed WebDav Server %s at http %s", util.Version(), listenAddress)
if err = httpS.Serve(webDavListener); err != nil {
glog.Fatalf("WebDav Server Fail to serve: %v", err)
}