mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-12 11:20:27 +08:00
[反向代理]增加请求主机名类型选择
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
|||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||||
"github.com/iwind/TeaGo/actions"
|
"github.com/iwind/TeaGo/actions"
|
||||||
|
"github.com/iwind/TeaGo/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SettingAction struct {
|
type SettingAction struct {
|
||||||
@@ -62,6 +63,11 @@ func (this *SettingAction) RunPost(params struct {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = reverseProxyConfig.Init()
|
||||||
|
if err != nil {
|
||||||
|
this.Fail("配置校验失败:" + err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
// 设置是否启用
|
// 设置是否启用
|
||||||
_, err = this.RPC().HTTPLocationRPC().UpdateHTTPLocationReverseProxy(this.AdminContext(), &pb.UpdateHTTPLocationReverseProxyRequest{
|
_, err = this.RPC().HTTPLocationRPC().UpdateHTTPLocationReverseProxy(this.AdminContext(), &pb.UpdateHTTPLocationReverseProxyRequest{
|
||||||
LocationId: params.LocationId,
|
LocationId: params.LocationId,
|
||||||
@@ -74,11 +80,12 @@ func (this *SettingAction) RunPost(params struct {
|
|||||||
|
|
||||||
// 设置反向代理相关信息
|
// 设置反向代理相关信息
|
||||||
_, err = this.RPC().ReverseProxyRPC().UpdateReverseProxy(this.AdminContext(), &pb.UpdateReverseProxyRequest{
|
_, err = this.RPC().ReverseProxyRPC().UpdateReverseProxy(this.AdminContext(), &pb.UpdateReverseProxyRequest{
|
||||||
ReverseProxyId: reverseProxyConfig.Id,
|
ReverseProxyId: reverseProxyConfig.Id,
|
||||||
RequestHost: reverseProxyConfig.RequestHost,
|
RequestHostType: types.Int32(reverseProxyConfig.RequestHostType),
|
||||||
RequestURI: reverseProxyConfig.RequestURI,
|
RequestHost: reverseProxyConfig.RequestHost,
|
||||||
StripPrefix: reverseProxyConfig.StripPrefix,
|
RequestURI: reverseProxyConfig.RequestURI,
|
||||||
AutoFlush: reverseProxyConfig.AutoFlush,
|
StripPrefix: reverseProxyConfig.StripPrefix,
|
||||||
|
AutoFlush: reverseProxyConfig.AutoFlush,
|
||||||
})
|
})
|
||||||
|
|
||||||
this.Success()
|
this.Success()
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||||
"github.com/iwind/TeaGo/actions"
|
"github.com/iwind/TeaGo/actions"
|
||||||
|
"github.com/iwind/TeaGo/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SettingAction struct {
|
type SettingAction struct {
|
||||||
@@ -62,6 +63,11 @@ func (this *SettingAction) RunPost(params struct {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = reverseProxyConfig.Init()
|
||||||
|
if err != nil {
|
||||||
|
this.Fail("配置校验失败:" + err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
// 设置是否启用
|
// 设置是否启用
|
||||||
_, err = this.RPC().ServerRPC().UpdateServerReverseProxy(this.AdminContext(), &pb.UpdateServerReverseProxyRequest{
|
_, err = this.RPC().ServerRPC().UpdateServerReverseProxy(this.AdminContext(), &pb.UpdateServerReverseProxyRequest{
|
||||||
ServerId: params.ServerId,
|
ServerId: params.ServerId,
|
||||||
@@ -74,11 +80,12 @@ func (this *SettingAction) RunPost(params struct {
|
|||||||
|
|
||||||
// 设置反向代理相关信息
|
// 设置反向代理相关信息
|
||||||
_, err = this.RPC().ReverseProxyRPC().UpdateReverseProxy(this.AdminContext(), &pb.UpdateReverseProxyRequest{
|
_, err = this.RPC().ReverseProxyRPC().UpdateReverseProxy(this.AdminContext(), &pb.UpdateReverseProxyRequest{
|
||||||
ReverseProxyId: reverseProxyConfig.Id,
|
ReverseProxyId: reverseProxyConfig.Id,
|
||||||
RequestHost: reverseProxyConfig.RequestHost,
|
RequestHostType: types.Int32(reverseProxyConfig.RequestHostType),
|
||||||
RequestURI: reverseProxyConfig.RequestURI,
|
RequestHost: reverseProxyConfig.RequestHost,
|
||||||
StripPrefix: reverseProxyConfig.StripPrefix,
|
RequestURI: reverseProxyConfig.RequestURI,
|
||||||
AutoFlush: reverseProxyConfig.AutoFlush,
|
StripPrefix: reverseProxyConfig.StripPrefix,
|
||||||
|
AutoFlush: reverseProxyConfig.AutoFlush,
|
||||||
})
|
})
|
||||||
|
|
||||||
this.Success()
|
this.Success()
|
||||||
|
|||||||
@@ -77,12 +77,12 @@ Vue.component("origin-list-table", {
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tr v-for="origin in vOrigins">
|
<tr v-for="origin in vOrigins">
|
||||||
<td>{{origin.addr}}
|
<td :class="{disabled:!origin.isOn}">{{origin.addr}}
|
||||||
<div v-if="origin.name.length > 0" style="margin-top: 0.5em">
|
<div v-if="origin.name.length > 0" style="margin-top: 0.5em">
|
||||||
<tiny-basic-label>{{origin.name}}</tiny-basic-label>
|
<tiny-basic-label>{{origin.name}}</tiny-basic-label>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>{{origin.weight}}</td>
|
<td :class="{disabled:!origin.isOn}">{{origin.weight}}</td>
|
||||||
<td>
|
<td>
|
||||||
<label-on :v-is-on="origin.isOn"></label-on>
|
<label-on :v-is-on="origin.isOn"></label-on>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -15,7 +15,9 @@ Vue.component("reverse-proxy-box", {
|
|||||||
reverseProxyConfig = {
|
reverseProxyConfig = {
|
||||||
requestPath: "",
|
requestPath: "",
|
||||||
stripPrefix: "",
|
stripPrefix: "",
|
||||||
requestURI: ""
|
requestURI: "",
|
||||||
|
requestHost: "",
|
||||||
|
requestHostType: 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
@@ -24,7 +26,16 @@ Vue.component("reverse-proxy-box", {
|
|||||||
advancedVisible: false
|
advancedVisible: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
watch: {
|
||||||
|
"reverseProxyConfig.requestHostType": function (v) {
|
||||||
|
let requestHostType = parseInt(v)
|
||||||
|
if (isNaN(requestHostType)) {
|
||||||
|
requestHostType = 0
|
||||||
|
}
|
||||||
|
this.reverseProxyConfig.requestHostType = requestHostType
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
isOn: function () {
|
isOn: function () {
|
||||||
return (!this.vIsLocation || this.reverseProxyRef.isPrior) && this.reverseProxyRef.isOn
|
return (!this.vIsLocation || this.reverseProxyRef.isPrior) && this.reverseProxyRef.isOn
|
||||||
},
|
},
|
||||||
@@ -47,16 +58,24 @@ Vue.component("reverse-proxy-box", {
|
|||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>请求主机名<em>(Host)</em></td>
|
||||||
|
<td>
|
||||||
|
<radio :v-value="0" v-model="reverseProxyConfig.requestHostType">跟随代理服务</radio>
|
||||||
|
<radio :v-value="1" 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">
|
||||||
|
<input type="text" placeholder="比如example.com" v-model="reverseProxyConfig.requestHost"/>
|
||||||
|
</div>
|
||||||
|
<p class="comment">请求源站时的Host,用于修改源站接收到的域名
|
||||||
|
<span v-if="reverseProxyConfig.requestHostType == 0">,"跟随代理服务"是指源站接收到的域名和当前代理服务保持一致</span>
|
||||||
|
<span v-if="reverseProxyConfig.requestHostType == 1">,"跟随源站"是指源站接收到的域名仍然是填写的源站地址中的信息,不随代理服务域名改变而改变</span>
|
||||||
|
<span v-if="reverseProxyConfig.requestHostType == 2">,自定义Host内容中支持请求变量</span>。</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">
|
||||||
<tr>
|
|
||||||
<td>请求主机名<em>(Host)</em></td>
|
|
||||||
<td>
|
|
||||||
<input type="text" placeholder="比如example.com" v-model="reverseProxyConfig.requestHost"/>
|
|
||||||
<p class="comment">请求后端服务器时的Host,用于修改后端服务器接收到的域名,默认和客户端请求的主机名一致,通常不必填写,支持请求变量。</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>请求URI<em>(RequestURI)</em></td>
|
<td>请求URI<em>(RequestURI)</em></td>
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
@@ -316,7 +316,7 @@ Vue.component("ssl-config-box", {
|
|||||||
<table class="ui table definition selectable">
|
<table class="ui table definition selectable">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr v-show="vProtocol == 'https'">
|
<tr v-show="vProtocol == 'https'">
|
||||||
<td class="title">用HTTP/2</td>
|
<td class="title">启用HTTP/2</td>
|
||||||
<td>
|
<td>
|
||||||
<div class="ui checkbox">
|
<div class="ui checkbox">
|
||||||
<input type="checkbox" value="1" v-model="policy.http2Enabled"/>
|
<input type="checkbox" value="1" v-model="policy.http2Enabled"/>
|
||||||
|
|||||||
@@ -52,7 +52,7 @@
|
|||||||
<td>参数名</td>
|
<td>参数名</td>
|
||||||
<td>
|
<td>
|
||||||
<input type="text" name="stickyParam" v-model="stickyParam" maxlength="50"/>
|
<input type="text" name="stickyParam" v-model="stickyParam" maxlength="50"/>
|
||||||
<p class="comment">记录或指定后端服务器的参数名,只能是英文字母和数字的组合,不允许有下划线(因为在HTTP Header中下划线是不标准的)</p>
|
<p class="comment">记录或指定源站的参数名,只能是英文字母和数字的组合,不允许有下划线(因为在HTTP Header中下划线是不标准的)</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -52,7 +52,7 @@
|
|||||||
<td>参数名</td>
|
<td>参数名</td>
|
||||||
<td>
|
<td>
|
||||||
<input type="text" name="stickyParam" v-model="stickyParam" maxlength="50"/>
|
<input type="text" name="stickyParam" v-model="stickyParam" maxlength="50"/>
|
||||||
<p class="comment">记录或指定后端服务器的参数名,只能是英文字母和数字的组合,不允许有下划线(因为在HTTP Header中下划线是不标准的)</p>
|
<p class="comment">记录或指定源站的参数名,只能是英文字母和数字的组合,不允许有下划线(因为在HTTP Header中下划线是不标准的)</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
Reference in New Issue
Block a user