From ee5955e6f7428caf45b47da066df5d6a72e22624 Mon Sep 17 00:00:00 2001 From: "user.email" Date: Sat, 24 Oct 2026 22:45:58 -0700 Subject: [PATCH] fix(volume): guard proxyProtocol flag for embedded volume starts --- weed/command/volume.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/weed/command/volume.go b/weed/command/volume.go index e69299130b..85949d759a 100644 --- a/weed/command/volume.go +++ b/weed/command/volume.go @@ -635,6 +635,13 @@ func (m multiHttpdownServer) Stop() error { return firstErr } +// acceptProxyProtocol reports whether volume listeners should unwrap PROXY +// v1 headers; the flag pointer is nil for embedded starts (server/mini) +// that do not register it. +func (v VolumeServerOptions) acceptProxyProtocol() bool { + return v.proxyProtocol != nil && *v.proxyProtocol +} + func (v VolumeServerOptions) startGrpcService(vs volume_server_pb.VolumeServerServer) *grpc.Server { grpcPort := *v.portGrpc grpcL, grpcLocalL, err := util.NewIpAndLocalListeners(*v.bindIp, grpcPort, 0) @@ -642,7 +649,7 @@ func (v VolumeServerOptions) startGrpcService(vs volume_server_pb.VolumeServerSe glog.Fatalf("failed to listen on grpc port %d: %v", grpcPort, err) } var grpcListener net.Listener = grpcL - if *v.proxyProtocol { + if v.acceptProxyProtocol() { grpcListener = util.WrapProxyProtocolListener(grpcListener) } grpcS := pb.NewGrpcServer(security.LoadServerTLS(util.GetViper(), "grpc.volume")) @@ -668,7 +675,7 @@ func (v VolumeServerOptions) startPublicHttpService(handler http.Handler) httpdo glog.Fatalf("Volume server listener error:%v", e) } var publicHttpListener net.Listener = publicListener - if *v.proxyProtocol { + if v.acceptProxyProtocol() { publicHttpListener = util.WrapProxyProtocolListener(publicHttpListener) } @@ -736,7 +743,7 @@ func (v VolumeServerOptions) startClusterHttpService(handler http.Handler) (http } var clusterHttpListener net.Listener = listener - if *v.proxyProtocol { + if v.acceptProxyProtocol() { clusterHttpListener = util.WrapProxyProtocolListener(clusterHttpListener) } clusterHttpServers := multiHttpdownServer{httpDown.Serve(httpS, clusterHttpListener)}