mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-03 20:40:26 +08:00
反向代理可以整体设置源站默认超时时间等参数
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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", {
|
||||
<p class="comment">开启后将自动刷新缓冲区数据到客户端,在类似于SSE(server-sent events)等场景下很有用。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="family == null || family == 'http'">
|
||||
<td class="color-border">源站默认连接失败超时时间</td>
|
||||
<td>
|
||||
<div class="ui fields inline">
|
||||
<div class="ui field">
|
||||
<input type="text" name="connTimeout" value="10" size="6" v-model="reverseProxyConfig.connTimeout.count"/>
|
||||
</div>
|
||||
<div class="ui field">
|
||||
秒
|
||||
</div>
|
||||
</div>
|
||||
<p class="comment">连接源站失败的最大超时时间,0表示不限制。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="family == null || family == 'http'">
|
||||
<td class="color-border">源站默认读取超时时间</td>
|
||||
<td>
|
||||
<div class="ui fields inline">
|
||||
<div class="ui field">
|
||||
<input type="text" name="readTimeout" value="0" size="6" v-model="reverseProxyConfig.readTimeout.count"/>
|
||||
</div>
|
||||
<div class="ui field">
|
||||
秒
|
||||
</div>
|
||||
</div>
|
||||
<p class="comment">读取内容时的最大超时时间,0表示不限制。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="family == null || family == 'http'">
|
||||
<td class="color-border">源站默认最大并发连接数</td>
|
||||
<td>
|
||||
<div class="ui fields inline">
|
||||
<div class="ui field">
|
||||
<input type="text" name="maxConns" value="0" size="6" maxlength="10" v-model="reverseProxyConfig.maxConns"/>
|
||||
</div>
|
||||
</div>
|
||||
<p class="comment">源站可以接受到的最大并发连接数,0表示使用系统默认。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="family == null || family == 'http'">
|
||||
<td class="color-border">源站默认最大空闲连接数</td>
|
||||
<td>
|
||||
<div class="ui fields inline">
|
||||
<div class="ui field">
|
||||
<input type="text" name="maxIdleConns" value="0" size="6" maxlength="10" v-model="reverseProxyConfig.maxIdleConns"/>
|
||||
</div>
|
||||
</div>
|
||||
<p class="comment">当没有请求时,源站保持等待的最大空闲连接数量,0表示使用系统默认。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="family == null || family == 'http'">
|
||||
<td class="color-border">源站默认最大空闲超时时间</td>
|
||||
<td>
|
||||
<div class="ui fields inline">
|
||||
<div class="ui field">
|
||||
<input type="text" name="idleTimeout" value="0" size="6" v-model="reverseProxyConfig.idleTimeout.count"/>
|
||||
</div>
|
||||
<div class="ui field">
|
||||
秒
|
||||
</div>
|
||||
</div>
|
||||
<p class="comment">源站保持等待的空闲超时时间,0表示使用默认时间。</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="margin"></div>
|
||||
|
||||
@@ -75,7 +75,7 @@
|
||||
<p class="comment">读取内容时的最大超时时间,0表示不限制。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr v-if="isHTTP">
|
||||
<td>最大并发连接数</td>
|
||||
<td>
|
||||
<div class="ui fields inline">
|
||||
|
||||
@@ -77,7 +77,7 @@
|
||||
<p class="comment">读取内容时的最大超时时间,0表示不限制。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr v-if="isHTTP">
|
||||
<td>最大并发连接数</td>
|
||||
<td>
|
||||
<div class="ui fields inline">
|
||||
|
||||
Reference in New Issue
Block a user