diff --git a/internal/web/actions/default/servers/server/settings/reverseProxy/setting.go b/internal/web/actions/default/servers/server/settings/reverseProxy/setting.go index 6fb63411..40af41d5 100644 --- a/internal/web/actions/default/servers/server/settings/reverseProxy/setting.go +++ b/internal/web/actions/default/servers/server/settings/reverseProxy/setting.go @@ -5,6 +5,7 @@ import ( "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs" + "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared" "github.com/iwind/TeaGo/actions" "github.com/iwind/TeaGo/types" ) @@ -68,6 +69,33 @@ func (this *SettingAction) RunPost(params struct { this.Fail("配置校验失败:" + err.Error()) } + if reverseProxyConfig.ConnTimeout == nil { + reverseProxyConfig.ConnTimeout = &shared.TimeDuration{Count: 0, Unit: "second"} + } + connTimeoutJSON, err := json.Marshal(reverseProxyConfig.ConnTimeout) + if err != nil { + this.ErrorPage(err) + return + } + + if reverseProxyConfig.ReadTimeout == nil { + reverseProxyConfig.ReadTimeout = &shared.TimeDuration{Count: 0, Unit: "second"} + } + readTimeoutJSON, err := json.Marshal(reverseProxyConfig.ReadTimeout) + if err != nil { + this.ErrorPage(err) + return + } + + if reverseProxyConfig.IdleTimeout == nil { + reverseProxyConfig.IdleTimeout = &shared.TimeDuration{Count: 0, Unit: "second"} + } + idleTimeoutJSON, err := json.Marshal(reverseProxyConfig.IdleTimeout) + if err != nil { + this.ErrorPage(err) + return + } + // 设置是否启用 _, err = this.RPC().ServerRPC().UpdateServerReverseProxy(this.AdminContext(), &pb.UpdateServerReverseProxyRequest{ ServerId: params.ServerId, @@ -87,6 +115,11 @@ func (this *SettingAction) RunPost(params struct { StripPrefix: reverseProxyConfig.StripPrefix, AutoFlush: reverseProxyConfig.AutoFlush, AddHeaders: reverseProxyConfig.AddHeaders, + ConnTimeoutJSON: connTimeoutJSON, + ReadTimeoutJSON: readTimeoutJSON, + IdleTimeoutJSON: idleTimeoutJSON, + MaxConns: types.Int32(reverseProxyConfig.MaxConns), + MaxIdleConns: types.Int32(reverseProxyConfig.MaxIdleConns), }) this.Success() diff --git a/web/public/js/components/server/reverse-proxy-box.js b/web/public/js/components/server/reverse-proxy-box.js index 57621e87..a2203256 100644 --- a/web/public/js/components/server/reverse-proxy-box.js +++ b/web/public/js/components/server/reverse-proxy-box.js @@ -18,11 +18,26 @@ Vue.component("reverse-proxy-box", { requestURI: "", requestHost: "", requestHostType: 0, - addHeaders: [] + addHeaders: [], + connTimeout: {count: 0, unit: "second"}, + readTimeout: {count: 0, unit: "second"}, + idleTimeout: {count: 0, unit: "second"}, + maxConns: 0, + maxIdleConns: 0 } - } else if (reverseProxyConfig.addHeaders == null) { + } + if (reverseProxyConfig.addHeaders == null) { reverseProxyConfig.addHeaders = [] } + if (reverseProxyConfig.connTimeout == null) { + reverseProxyConfig.connTimeout = {count: 0, unit: "second"} + } + if (reverseProxyConfig.readTimeout == null) { + reverseProxyConfig.readTimeout = {count: 0, unit: "second"} + } + if (reverseProxyConfig.idleTimeout == null) { + reverseProxyConfig.idleTimeout = {count: 0, unit: "second"} + } let forwardHeaders = [ { @@ -65,7 +80,42 @@ Vue.component("reverse-proxy-box", { requestHostType = 0 } this.reverseProxyConfig.requestHostType = requestHostType - } + }, + "reverseProxyConfig.connTimeout.count": function (v) { + let count = parseInt(v) + if (isNaN(count) || count < 0) { + count = 0 + } + this.reverseProxyConfig.connTimeout.count = count + }, + "reverseProxyConfig.readTimeout.count": function (v) { + let count = parseInt(v) + if (isNaN(count) || count < 0) { + count = 0 + } + this.reverseProxyConfig.readTimeout.count = count + }, + "reverseProxyConfig.idleTimeout.count": function (v) { + let count = parseInt(v) + if (isNaN(count) || count < 0) { + count = 0 + } + this.reverseProxyConfig.idleTimeout.count = count + }, + "reverseProxyConfig.maxConns": function (v) { + let maxConns = parseInt(v) + if (isNaN(maxConns) || maxConns < 0) { + maxConns = 0 + } + this.reverseProxyConfig.maxConns = maxConns + }, + "reverseProxyConfig.maxIdleConns": function (v) { + let maxIdleConns = parseInt(v) + if (isNaN(maxIdleConns) || maxIdleConns < 0) { + maxIdleConns = 0 + } + this.reverseProxyConfig.maxIdleConns = maxIdleConns + }, }, methods: { isOn: function () { @@ -151,6 +201,70 @@ Vue.component("reverse-proxy-box", {
开启后将自动刷新缓冲区数据到客户端,在类似于SSE(server-sent events)等场景下很有用。
+连接源站失败的最大超时时间,0表示不限制。
+读取内容时的最大超时时间,0表示不限制。
+源站可以接受到的最大并发连接数,0表示使用系统默认。
+当没有请求时,源站保持等待的最大空闲连接数量,0表示使用系统默认。
+源站保持等待的空闲超时时间,0表示使用默认时间。
+读取内容时的最大超时时间,0表示不限制。
-读取内容时的最大超时时间,0表示不限制。