反向代理设置中增加移除回源主机名端口功能

This commit is contained in:
刘祥超
2022-06-30 12:11:17 +08:00
parent c454cd75b3
commit a56a29495e
2 changed files with 25 additions and 19 deletions

View File

@@ -55,9 +55,7 @@ func (this *SettingAction) RunPost(params struct {
}) { }) {
defer this.CreateLogInfo("修改代理服务 %d 的反向代理设置", params.ServerId) defer this.CreateLogInfo("修改代理服务 %d 的反向代理设置", params.ServerId)
// TODO 校验配置 var reverseProxyConfig = &serverconfigs.ReverseProxyConfig{}
reverseProxyConfig := &serverconfigs.ReverseProxyConfig{}
err := json.Unmarshal(params.ReverseProxyJSON, reverseProxyConfig) err := json.Unmarshal(params.ReverseProxyJSON, reverseProxyConfig)
if err != nil { if err != nil {
this.ErrorPage(err) this.ErrorPage(err)
@@ -132,6 +130,7 @@ func (this *SettingAction) RunPost(params struct {
MaxIdleConns: types.Int32(reverseProxyConfig.MaxIdleConns), MaxIdleConns: types.Int32(reverseProxyConfig.MaxIdleConns),
ProxyProtocolJSON: proxyProtocolJSON, ProxyProtocolJSON: proxyProtocolJSON,
FollowRedirects: reverseProxyConfig.FollowRedirects, FollowRedirects: reverseProxyConfig.FollowRedirects,
RequestHostExcludingPort: reverseProxyConfig.RequestHostExcludingPort,
}) })
if err != nil { if err != nil {
this.ErrorPage(err) this.ErrorPage(err)

View File

@@ -18,6 +18,7 @@ Vue.component("reverse-proxy-box", {
requestURI: "", requestURI: "",
requestHost: "", requestHost: "",
requestHostType: 0, requestHostType: 0,
requestHostExcludingPort: false,
addHeaders: [], addHeaders: [],
connTimeout: {count: 0, unit: "second"}, connTimeout: {count: 0, unit: "second"},
readTimeout: {count: 0, unit: "second"}, readTimeout: {count: 0, unit: "second"},
@@ -169,18 +170,24 @@ Vue.component("reverse-proxy-box", {
<tr v-show="family == null || family == 'http'"> <tr v-show="family == null || family == 'http'">
<td>回源主机名<em>Host</em></td> <td>回源主机名<em>Host</em></td>
<td> <td>
<radio :v-value="0" v-model="reverseProxyConfig.requestHostType">跟随代理服务</radio> &nbsp; <radio :v-value="0" v-model="reverseProxyConfig.requestHostType">跟随CDN域名</radio> &nbsp;
<radio :v-value="1" v-model="reverseProxyConfig.requestHostType">跟随源站</radio> &nbsp; <radio :v-value="1" v-model="reverseProxyConfig.requestHostType">跟随源站</radio> &nbsp;
<radio :v-value="2" v-model="reverseProxyConfig.requestHostType">自定义</radio> <radio :v-value="2" v-model="reverseProxyConfig.requestHostType">自定义</radio>
<div v-show="reverseProxyConfig.requestHostType == 2" style="margin-top: 0.8em"> <div v-show="reverseProxyConfig.requestHostType == 2" style="margin-top: 0.8em">
<input type="text" placeholder="比如example.com" v-model="reverseProxyConfig.requestHost"/> <input type="text" placeholder="比如example.com" v-model="reverseProxyConfig.requestHost"/>
</div> </div>
<p class="comment">请求源站时的Host用于修改源站接收到的域名 <p class="comment">请求源站时的Host用于修改源站接收到的域名
<span v-if="reverseProxyConfig.requestHostType == 0">"跟随代理服务"是指源站接收到的域名和当前代理服务保持一致</span> <span v-if="reverseProxyConfig.requestHostType == 0">"跟随CDN域名"是指源站接收到的域名和当前CDN访问域名保持一致</span>
<span v-if="reverseProxyConfig.requestHostType == 1">"跟随源站"是指源站接收到的域名仍然是填写的源站地址中的信息,不随代理服务域名改变而改变</span> <span v-if="reverseProxyConfig.requestHostType == 1">"跟随源站"是指源站接收到的域名仍然是填写的源站地址中的信息,不随代理服务域名改变而改变</span>
<span v-if="reverseProxyConfig.requestHostType == 2">自定义Host内容中支持请求变量</span>。</p> <span v-if="reverseProxyConfig.requestHostType == 2">自定义Host内容中支持请求变量</span>。</p>
</td> </td>
</tr> </tr>
<tr v-show="family == null || family == 'http'">
<td>回源主机名不包含端口</td>
<td><checkbox v-model="reverseProxyConfig.requestHostExcludingPort"></checkbox>
<p class="comment">选中后表示移除回源主机名中的端口部分。</p>
</td>
</tr>
</tbody> </tbody>
<more-options-tbody @change="changeAdvancedVisible" v-if="isOn()"></more-options-tbody> <more-options-tbody @change="changeAdvancedVisible" v-if="isOn()"></more-options-tbody>
<tbody v-show="isOn() && advancedVisible"> <tbody v-show="isOn() && advancedVisible">