反向代理可以整体设置源站默认超时时间等参数

This commit is contained in:
刘祥超
2021-03-26 22:08:18 +08:00
parent de90acaae4
commit 7a24a69223
4 changed files with 152 additions and 5 deletions

View File

@@ -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">开启后将自动刷新缓冲区数据到客户端在类似于SSEserver-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>