enhance: Make Web UI toggleable via config (#42814)

issue: #42813

---------

Signed-off-by: Cai Zhang <cai.zhang@zilliz.com>
This commit is contained in:
cai.zhang 2025-06-18 13:02:38 +08:00 committed by GitHub
parent 6bebb68727
commit d122e6d1e2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 15 additions and 1 deletions

View File

@ -354,6 +354,7 @@ proxy:
hstsMaxAge: 31536000 # Strict-Transport-Security max-age in seconds
hstsIncludeSubDomains: false # Include subdomains in Strict-Transport-Security
enableHSTS: false # Whether to enable setting the Strict-Transport-Security header
enableWebUI: true # Whether to enable setting the WebUI middleware on the metrics port
ip: # TCP/IP address of proxy. If not specified, use the first unicastable address
port: 19530 # TCP port of proxy
internalPort: 19529

View File

@ -103,7 +103,9 @@ func registerDefaults() {
Handler: GetStaticHandler(),
})
RegisterWebUIHandler()
if paramtable.Get().HTTPCfg.EnableWebUI.GetAsBool() {
RegisterWebUIHandler()
}
}
func RegisterStopComponent(triggerComponentStop func(role string) error) {

View File

@ -26,6 +26,7 @@ type httpConfig struct {
HSTSMaxAge ParamItem `refreshable:"false"`
HSTSIncludeSubDomains ParamItem `refreshable:"false"`
EnableHSTS ParamItem `refreshable:"false"`
EnableWebUI ParamItem `refreshable:"false"`
}
func (p *httpConfig) init(base *BaseTable) {
@ -110,4 +111,13 @@ func (p *httpConfig) init(base *BaseTable) {
Export: true,
}
p.EnableHSTS.Init(base.mgr)
p.EnableWebUI = ParamItem{
Key: "proxy.http.enableWebUI",
DefaultValue: "true",
Version: "v2.5.14",
Doc: "Whether to enable setting the WebUI middleware on the metrics port",
Export: true,
}
p.EnableWebUI.Init(base.mgr)
}

View File

@ -31,4 +31,5 @@ func TestHTTPConfig_Init(t *testing.T) {
assert.Equal(t, cfg.Port.GetValue(), "")
assert.Equal(t, cfg.AcceptTypeAllowInt64.GetValue(), "true")
assert.Equal(t, cfg.EnablePprof.GetAsBool(), true)
assert.Equal(t, cfg.EnableWebUI.GetAsBool(), true)
}