反向代理支持RequestPath、RequestURI等

This commit is contained in:
GoEdgeLab
2020-09-27 10:03:00 +08:00
parent 7be35b2965
commit 09763d4d60
20 changed files with 281 additions and 165 deletions

View File

@@ -5,7 +5,6 @@ import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils" "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"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/maps" "github.com/iwind/TeaGo/maps"
) )
@@ -40,6 +39,7 @@ func (this *IndexAction) RunGet(params struct {
this.ErrorPage(err) this.ErrorPage(err)
return return
} }
this.Data["reverseProxyRef"] = reverseProxyRef
reverseProxy := &serverconfigs.ReverseProxyConfig{} reverseProxy := &serverconfigs.ReverseProxyConfig{}
err = json.Unmarshal(reverseProxyResp.ReverseProxyJSON, reverseProxy) err = json.Unmarshal(reverseProxyResp.ReverseProxyJSON, reverseProxy)
@@ -47,10 +47,9 @@ func (this *IndexAction) RunGet(params struct {
this.ErrorPage(err) this.ErrorPage(err)
return return
} }
this.Data["reverseProxyConfig"] = reverseProxy
this.Data["serverType"] = serverType this.Data["serverType"] = serverType
this.Data["reverseProxyRef"] = reverseProxyRef
this.Data["reverseProxyConfig"] = reverseProxy
primaryOriginMaps := []maps.Map{} primaryOriginMaps := []maps.Map{}
backupOriginMaps := []maps.Map{} backupOriginMaps := []maps.Map{}
@@ -75,23 +74,3 @@ func (this *IndexAction) RunGet(params struct {
this.Show() this.Show()
} }
func (this *IndexAction) RunPost(params struct {
LocationId int64
ReverseProxyRefJSON []byte
Must *actions.Must
}) {
// TODO 校验配置
_, err := this.RPC().HTTPLocationRPC().UpdateHTTPLocationReverseProxy(this.AdminContext(), &pb.UpdateHTTPLocationReverseProxyRequest{
LocationId: params.LocationId,
ReverseProxyJSON: params.ReverseProxyRefJSON,
})
if err != nil {
this.ErrorPage(err)
return
}
this.Success()
}

View File

@@ -16,8 +16,9 @@ func init() {
Data("mainTab", "setting"). Data("mainTab", "setting").
Data("tinyMenuItem", "reverseProxy"). Data("tinyMenuItem", "reverseProxy").
Prefix("/servers/server/settings/locations/reverseProxy"). Prefix("/servers/server/settings/locations/reverseProxy").
GetPost("", new(IndexAction)). Get("", new(IndexAction)).
GetPost("/scheduling", new(SchedulingAction)). GetPost("/scheduling", new(SchedulingAction)).
GetPost("/setting", new(SettingAction)).
EndAll() EndAll()
}) })
} }

View File

@@ -0,0 +1,82 @@
package reverseProxy
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
"github.com/iwind/TeaGo/actions"
)
type SettingAction struct {
actionutils.ParentAction
}
func (this *SettingAction) Init() {
this.FirstMenu("setting")
}
func (this *SettingAction) RunGet(params struct {
LocationId int64
}) {
reverseProxyResp, err := this.RPC().HTTPLocationRPC().FindAndInitHTTPLocationReverseProxyConfig(this.AdminContext(), &pb.FindAndInitHTTPLocationReverseProxyConfigRequest{LocationId: params.LocationId})
if err != nil {
this.ErrorPage(err)
return
}
reverseProxyRef := &serverconfigs.ReverseProxyRef{}
err = json.Unmarshal(reverseProxyResp.ReverseProxyRefJSON, reverseProxyRef)
if err != nil {
this.ErrorPage(err)
return
}
reverseProxy := &serverconfigs.ReverseProxyConfig{}
err = json.Unmarshal(reverseProxyResp.ReverseProxyJSON, reverseProxy)
if err != nil {
this.ErrorPage(err)
return
}
this.Data["reverseProxyRef"] = reverseProxyRef
this.Data["reverseProxyConfig"] = reverseProxy
this.Show()
}
func (this *SettingAction) RunPost(params struct {
LocationId int64
ReverseProxyRefJSON []byte
ReverseProxyJSON []byte
Must *actions.Must
}) {
// TODO 校验配置
reverseProxyConfig := &serverconfigs.ReverseProxyConfig{}
err := json.Unmarshal(params.ReverseProxyJSON, reverseProxyConfig)
if err != nil {
this.ErrorPage(err)
return
}
// 设置是否启用
_, err = this.RPC().HTTPLocationRPC().UpdateHTTPLocationReverseProxy(this.AdminContext(), &pb.UpdateHTTPLocationReverseProxyRequest{
LocationId: params.LocationId,
ReverseProxyJSON: params.ReverseProxyRefJSON,
})
if err != nil {
this.ErrorPage(err)
return
}
// 设置反向代理相关信息
_, err = this.RPC().ReverseProxyRPC().UpdateReverseProxy(this.AdminContext(), &pb.UpdateReverseProxyRequest{
ReverseProxyId: reverseProxyConfig.Id,
RequestHost: reverseProxyConfig.RequestHost,
RequestURI: reverseProxyConfig.RequestURI,
StripPrefix: reverseProxyConfig.StripPrefix,
})
this.Success()
}

View File

@@ -5,7 +5,6 @@ import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils" "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"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/maps" "github.com/iwind/TeaGo/maps"
) )
@@ -39,6 +38,7 @@ func (this *IndexAction) RunGet(params struct {
this.ErrorPage(err) this.ErrorPage(err)
return return
} }
this.Data["reverseProxyRef"] = reverseProxyRef
reverseProxy := &serverconfigs.ReverseProxyConfig{} reverseProxy := &serverconfigs.ReverseProxyConfig{}
err = json.Unmarshal(reverseProxyResp.ReverseProxyJSON, reverseProxy) err = json.Unmarshal(reverseProxyResp.ReverseProxyJSON, reverseProxy)
@@ -46,10 +46,9 @@ func (this *IndexAction) RunGet(params struct {
this.ErrorPage(err) this.ErrorPage(err)
return return
} }
this.Data["reverseProxyConfig"] = reverseProxy
this.Data["serverType"] = serverType this.Data["serverType"] = serverType
this.Data["reverseProxyRef"] = reverseProxyRef
this.Data["reverseProxyConfig"] = reverseProxy
primaryOriginMaps := []maps.Map{} primaryOriginMaps := []maps.Map{}
backupOriginMaps := []maps.Map{} backupOriginMaps := []maps.Map{}
@@ -74,23 +73,3 @@ func (this *IndexAction) RunGet(params struct {
this.Show() this.Show()
} }
func (this *IndexAction) RunPost(params struct {
ServerId int64
ReverseProxyRefJSON []byte
Must *actions.Must
}) {
// TODO 校验配置
_, err := this.RPC().ServerRPC().UpdateServerReverseProxy(this.AdminContext(), &pb.UpdateServerReverseProxyRequest{
ServerId: params.ServerId,
ReverseProxyJSON: params.ReverseProxyRefJSON,
})
if err != nil {
this.ErrorPage(err)
return
}
this.Success()
}

View File

@@ -14,10 +14,10 @@ func init() {
Data("mainTab", "setting"). Data("mainTab", "setting").
Data("secondMenuItem", "reverseProxy"). Data("secondMenuItem", "reverseProxy").
Prefix("/servers/server/settings/reverseProxy"). Prefix("/servers/server/settings/reverseProxy").
GetPost("", new(IndexAction)). Get("", new(IndexAction)).
GetPost("/scheduling", new(SchedulingAction)). GetPost("/scheduling", new(SchedulingAction)).
GetPost("/updateSchedulingPopup", new(UpdateSchedulingPopupAction)). GetPost("/updateSchedulingPopup", new(UpdateSchedulingPopupAction)).
Post("/updateOn", new(UpdateOnAction)). GetPost("/setting", new(SettingAction)).
EndAll() EndAll()
}) })
} }

View File

@@ -0,0 +1,82 @@
package reverseProxy
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
"github.com/iwind/TeaGo/actions"
)
type SettingAction struct {
actionutils.ParentAction
}
func (this *SettingAction) Init() {
this.FirstMenu("setting")
}
func (this *SettingAction) RunGet(params struct {
ServerId int64
}) {
reverseProxyResp, err := this.RPC().ServerRPC().FindAndInitServerReverseProxyConfig(this.AdminContext(), &pb.FindAndInitServerReverseProxyConfigRequest{ServerId: params.ServerId})
if err != nil {
this.ErrorPage(err)
return
}
reverseProxyRef := &serverconfigs.ReverseProxyRef{}
err = json.Unmarshal(reverseProxyResp.ReverseProxyRefJSON, reverseProxyRef)
if err != nil {
this.ErrorPage(err)
return
}
reverseProxy := &serverconfigs.ReverseProxyConfig{}
err = json.Unmarshal(reverseProxyResp.ReverseProxyJSON, reverseProxy)
if err != nil {
this.ErrorPage(err)
return
}
this.Data["reverseProxyRef"] = reverseProxyRef
this.Data["reverseProxyConfig"] = reverseProxy
this.Show()
}
func (this *SettingAction) RunPost(params struct {
ServerId int64
ReverseProxyRefJSON []byte
ReverseProxyJSON []byte
Must *actions.Must
}) {
// TODO 校验配置
reverseProxyConfig := &serverconfigs.ReverseProxyConfig{}
err := json.Unmarshal(params.ReverseProxyJSON, reverseProxyConfig)
if err != nil {
this.ErrorPage(err)
return
}
// 设置是否启用
_, err = this.RPC().ServerRPC().UpdateServerReverseProxy(this.AdminContext(), &pb.UpdateServerReverseProxyRequest{
ServerId: params.ServerId,
ReverseProxyJSON: params.ReverseProxyRefJSON,
})
if err != nil {
this.ErrorPage(err)
return
}
// 设置反向代理相关信息
_, err = this.RPC().ReverseProxyRPC().UpdateReverseProxy(this.AdminContext(), &pb.UpdateReverseProxyRequest{
ReverseProxyId: reverseProxyConfig.Id,
RequestHost: reverseProxyConfig.RequestHost,
RequestURI: reverseProxyConfig.RequestURI,
StripPrefix: reverseProxyConfig.StripPrefix,
})
this.Success()
}

View File

@@ -1,68 +0,0 @@
package reverseProxy
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
)
type UpdateOnAction struct {
actionutils.ParentAction
}
func (this *UpdateOnAction) RunPost(params struct {
ServerId int64
ReverseProxyId int64
IsOn bool
}) {
// 如果没有配置过,则配置
if params.ReverseProxyId <= 0 {
if !params.IsOn {
this.Success()
}
resp, err := this.RPC().ReverseProxyRPC().CreateReverseProxy(this.AdminContext(), &pb.CreateReverseProxyRequest{
SchedulingJSON: nil,
PrimaryOriginsJSON: nil,
BackupOriginsJSON: nil,
})
if err != nil {
this.ErrorPage(err)
return
}
reverseProxyId := resp.ReverseProxyId
ref := &serverconfigs.ReverseProxyRef{
IsOn: true,
ReverseProxyId: reverseProxyId,
}
refJSON, err := json.Marshal(ref)
if err != nil {
this.ErrorPage(err)
return
}
_, err = this.RPC().ServerRPC().UpdateServerReverseProxy(this.AdminContext(), &pb.UpdateServerReverseProxyRequest{
ServerId: params.ServerId,
ReverseProxyJSON: refJSON,
})
if err != nil {
this.ErrorPage(err)
return
}
this.Success()
}
// 如果已经配置过
_, err := this.RPC().ReverseProxyRPC().UpdateReverseProxyIsOn(this.AdminContext(), &pb.UpdateReverseProxyIsOnRequest{
ReverseProxyId: params.ReverseProxyId,
IsOn: params.IsOn,
})
if err != nil {
this.ErrorPage(err)
return
}
this.Success()
}

View File

@@ -42,6 +42,7 @@ Vue.component("http-web-root-box", {
} }
}, },
template: `<div> template: `<div>
<p class="ui message">在这里可以设置如何分发静态文件资源。</p>
<input type="hidden" name="rootJSON" :value="JSON.stringify(rootConfig)"/> <input type="hidden" name="rootJSON" :value="JSON.stringify(rootConfig)"/>
<table class="ui table selectable definition"> <table class="ui table selectable definition">
<prior-checkbox :v-config="rootConfig" v-if="vIsLocation"></prior-checkbox> <prior-checkbox :v-config="rootConfig" v-if="vIsLocation"></prior-checkbox>
@@ -86,7 +87,7 @@ Vue.component("http-web-root-box", {
<td>去除URL前缀</td> <td>去除URL前缀</td>
<td> <td>
<input type="text" v-model="rootConfig.stripPrefix" placeholder="/PREFIX"/> <input type="text" v-model="rootConfig.stripPrefix" placeholder="/PREFIX"/>
<p class="comment">可以把请求的路径部分前缀去除后再查找文件,比如把 <span class="ui label tiny">/web/app/index.html</span> 去除前缀 <span class="ui label tiny">/web</span> 后就变成 <span class="ui label tiny">/app/index.html</span> </p> <p class="comment">可以把请求的路径部分前缀去除后再查找文件,比如把 <span class="ui label tiny">/web/app/index.html</span> 去除前缀 <span class="ui label tiny">/web</span> 后就变成 <span class="ui label tiny">/app/index.html</span> </p>
</td> </td>
</tr> </tr>
<tr> <tr>

View File

@@ -91,7 +91,7 @@ Vue.component("http-websocket-box", {
</tbody> </tbody>
<tbody v-show="isOn()"> <tbody v-show="isOn()">
<tr> <tr>
<td>允许所有来源域<em>Origin</em></td> <td class="color-border">允许所有来源域<em>Origin</em></td>
<td> <td>
<div class="ui checkbox"> <div class="ui checkbox">
<input type="checkbox" v-model="websocketConfig.allowAllOrigins"/> <input type="checkbox" v-model="websocketConfig.allowAllOrigins"/>
@@ -103,7 +103,7 @@ Vue.component("http-websocket-box", {
</tbody> </tbody>
<tbody v-show="isOn() && !websocketConfig.allowAllOrigins"> <tbody v-show="isOn() && !websocketConfig.allowAllOrigins">
<tr> <tr>
<td>允许的来源域列表<em>Origin</em></td> <td class="color-border">允许的来源域列表<em>Origin</em></td>
<td> <td>
<div v-if="websocketConfig.allowedOrigins.length > 0"> <div v-if="websocketConfig.allowedOrigins.length > 0">
<div class="ui label tiny" v-for="(origin, index) in websocketConfig.allowedOrigins"> <div class="ui label tiny" v-for="(origin, index) in websocketConfig.allowedOrigins">
@@ -119,7 +119,7 @@ Vue.component("http-websocket-box", {
<more-options-tbody @change="changeAdvancedVisible" v-show="isOn()"></more-options-tbody> <more-options-tbody @change="changeAdvancedVisible" v-show="isOn()"></more-options-tbody>
<tbody v-show="isOn() && advancedVisible"> <tbody v-show="isOn() && advancedVisible">
<tr> <tr>
<td>是否传递请求来源域</td> <td class="color-border">是否传递请求来源域</td>
<td> <td>
<div class="ui checkbox"> <div class="ui checkbox">
<input type="checkbox" v-model="websocketConfig.requestSameOrigin"/> <input type="checkbox" v-model="websocketConfig.requestSameOrigin"/>
@@ -131,7 +131,7 @@ Vue.component("http-websocket-box", {
</tbody> </tbody>
<tbody v-show="isOn() && advancedVisible && !websocketConfig.requestSameOrigin"> <tbody v-show="isOn() && advancedVisible && !websocketConfig.requestSameOrigin">
<tr> <tr>
<td>指定传递的来源域</td> <td class="color-border">指定传递的来源域</td>
<td> <td>
<input type="text" v-model="websocketConfig.requestOrigin" maxlength="200"/> <input type="text" v-model="websocketConfig.requestOrigin" maxlength="200"/>
<p class="comment">指定向源站传递的<span class="ui label tiny">Origin</span>字段值。</p> <p class="comment">指定向源站传递的<span class="ui label tiny">Origin</span>字段值。</p>

View File

@@ -41,7 +41,7 @@ Vue.component("origin-list-box", {
}, },
template: `<div> template: `<div>
<h3>主要源站 <a href="" @click.prevent="createPrimaryOrigin()">[添加主要源站]</a> </h3> <h3>主要源站 <a href="" @click.prevent="createPrimaryOrigin()">[添加主要源站]</a> </h3>
<p class="comment" v-if="primaryOrigins.length == 0">暂时还没有优先源站。</p> <p class="comment" v-if="primaryOrigins.length == 0">暂时还没有主要源站。</p>
<origin-list-table v-if="primaryOrigins.length > 0" :v-origins="vPrimaryOrigins" :v-origin-type="'primary'" @deleteOrigin="deleteOrigin" @updateOrigin="updateOrigin"></origin-list-table> <origin-list-table v-if="primaryOrigins.length > 0" :v-origins="vPrimaryOrigins" :v-origin-type="'primary'" @deleteOrigin="deleteOrigin" @updateOrigin="updateOrigin"></origin-list-table>
<h3>备用源站 <a href="" @click.prevent="createBackupOrigin()">[添加备用源站]</a></h3> <h3>备用源站 <a href="" @click.prevent="createBackupOrigin()">[添加备用源站]</a></h3>

View File

@@ -1,5 +1,5 @@
Vue.component("reverse-proxy-box", { Vue.component("reverse-proxy-box", {
props: ["v-reverse-proxy-ref", "v-is-location"], props: ["v-reverse-proxy-ref", "v-reverse-proxy-config", "v-is-location"],
data: function () { data: function () {
let reverseProxyRef = this.vReverseProxyRef let reverseProxyRef = this.vReverseProxyRef
if (reverseProxyRef == null) { if (reverseProxyRef == null) {
@@ -9,12 +9,32 @@ Vue.component("reverse-proxy-box", {
reverseProxyId: 0 reverseProxyId: 0
} }
} }
let reverseProxyConfig = this.vReverseProxyConfig
if (reverseProxyConfig == null) {
reverseProxyConfig = {
requestPath: "",
stripPrefix: "",
requestURI: ""
}
}
return { return {
reverseProxyRef: reverseProxyRef reverseProxyRef: reverseProxyRef,
reverseProxyConfig: reverseProxyConfig,
advancedVisible: false
}
},
methods: {
isOn: function () {
return (!this.vIsLocation || this.reverseProxyRef.isPrior) && this.reverseProxyRef.isOn
},
changeAdvancedVisible: function (v) {
this.advancedVisible = v
} }
}, },
template: `<div> template: `<div>
<input type="hidden" name="reverseProxyRefJSON" :value="JSON.stringify(reverseProxyRef)"/> <input type="hidden" name="reverseProxyRefJSON" :value="JSON.stringify(reverseProxyRef)"/>
<input type="hidden" name="reverseProxyJSON" :value="JSON.stringify(reverseProxyConfig)"/>
<table class="ui table selectable definition"> <table class="ui table selectable definition">
<prior-checkbox :v-config="reverseProxyRef" v-if="vIsLocation"></prior-checkbox> <prior-checkbox :v-config="reverseProxyRef" v-if="vIsLocation"></prior-checkbox>
<tbody v-show="!vIsLocation || reverseProxyRef.isPrior"> <tbody v-show="!vIsLocation || reverseProxyRef.isPrior">
@@ -28,6 +48,30 @@ Vue.component("reverse-proxy-box", {
</td> </td>
</tr> </tr>
</tbody> </tbody>
<more-options-tbody @change="changeAdvancedVisible" v-if="isOn()"></more-options-tbody>
<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>
<td>请求URI</td>
<td>
<input type="text" placeholder="\${requestURI}" v-model="reverseProxyConfig.requestURI"/>
<p class="comment">\${requestURI}为完整的请求URI可以使用类似于"\${requestURI}?arg1=value1&arg2=value2"的形式添加你的参数。</p>
</td>
</tr>
<tr>
<td>去除URL前缀</td>
<td>
<input type="text" v-model="reverseProxyConfig.stripPrefix" placeholder="/PREFIX"/>
<p class="comment">可以把请求的路径部分前缀去除后再查找文件,比如把 <span class="ui label tiny">/web/app/index.html</span> 去除前缀 <span class="ui label tiny">/web</span> 后就变成 <span class="ui label tiny">/app/index.html</span>。 </p>
</td>
</tr>
</tbody>
</table> </table>
<div class="margin"></div> <div class="margin"></div>
</div>` </div>`

View File

@@ -1,4 +1,5 @@
<first-menu> <first-menu>
<menu-item :href="'/servers/server/settings/locations/reverseProxy?serverId=' + serverId + '&locationId=' + locationId" code="index">源站列表</menu-item> <menu-item :href="'/servers/server/settings/locations/reverseProxy?serverId=' + serverId + '&locationId=' + locationId" code="index">源站列表</menu-item>
<menu-item :href="'/servers/server/settings/locations/reverseProxy/scheduling?serverId=' + serverId + '&locationId=' + locationId" code="scheduling">调度算法</menu-item> <menu-item :href="'/servers/server/settings/locations/reverseProxy/scheduling?serverId=' + serverId + '&locationId=' + locationId" code="scheduling">调度算法</menu-item>
<menu-item :href="'/servers/server/settings/locations/reverseProxy/setting?serverId=' + serverId + '&locationId=' + locationId" code="setting">更多设置</menu-item>
</first-menu> </first-menu>

View File

@@ -8,17 +8,13 @@
<div class="right-box tiny"> <div class="right-box tiny">
{$template "menu"} {$template "menu"}
<div class="margin"></div> <div class="margin"></div>
<form class="ui form" data-tea-action="$" data-tea-success="success"> <div v-if="!reverseProxyRef.isPrior || !reverseProxyRef.isOn">
<input type="hidden" name="locationId" :value="locationId"/> <div class="margin"></div>
<reverse-proxy-box :v-reverse-proxy-ref="reverseProxyRef" :v-is-location="true"></reverse-proxy-box> <p class="ui message warning">当前代理服务没有开启,可以通过点击 <a :href="'/servers/server/settings/locations/reverseProxy/setting?serverId=' + serverId + '&locationId=' + locationId">[更多设置]</a> 开启 。</p>
<submit-btn></submit-btn> </div>
</form>
<div v-if="reverseProxyRef.isPrior && reverseProxyRef.isOn">
<div class="ui divider"></div>
<origin-list-box :v-primary-origins="primaryOrigins" :v-backup-origins="backupOrigins" <origin-list-box :v-primary-origins="primaryOrigins" :v-backup-origins="backupOrigins"
:v-server-type="serverType" :v-server-type="serverType"
:v-params="'type=server&serverId=' + serverId + '&reverseProxyId=' + reverseProxyConfig.id"></origin-list-box> :v-params="'type=server&serverId=' + serverId + '&reverseProxyId=' + reverseProxyConfig.id"></origin-list-box>
</div> </div>
</div>
</div> </div>

View File

@@ -0,0 +1,20 @@
{$layout}
{$template "/left_menu"}
<div class="right-box">
{$template "../location_menu"}
{$template "../left_menu"}
<div class="right-box tiny">
{$template "menu"}
<div class="margin"></div>
<form class="ui form" data-tea-action="$" data-tea-success="success">
<input type="hidden" name="locationId" :value="locationId"/>
<input type="hidden" name="reverseProxyRefJSON" :value="JSON.stringify(reverseProxyRef)"/>
<reverse-proxy-box :v-reverse-proxy-ref="reverseProxyRef"
:v-reverse-proxy-config="reverseProxyConfig"
:v-is-location="true"></reverse-proxy-box>
<submit-btn></submit-btn>
</form>
</div>
</div>

View File

@@ -0,0 +1,3 @@
Tea.context(function () {
this.success = NotifyReloadSuccess("保存成功")
})

View File

@@ -1,4 +1,5 @@
<first-menu> <first-menu>
<menu-item :href="'/servers/server/settings/reverseProxy?serverId=' + serverId" code="index">源站列表</menu-item> <menu-item :href="'/servers/server/settings/reverseProxy?serverId=' + serverId" code="index">源站列表</menu-item>
<menu-item :href="'/servers/server/settings/reverseProxy/scheduling?serverId=' + serverId" code="scheduling">调度算法</menu-item> <menu-item :href="'/servers/server/settings/reverseProxy/scheduling?serverId=' + serverId" code="scheduling">调度算法</menu-item>
<menu-item :href="'/servers/server/settings/reverseProxy/setting?serverId=' + serverId" code="setting">更多设置</menu-item>
</first-menu> </first-menu>

View File

@@ -4,17 +4,12 @@
<div class="right-box"> <div class="right-box">
{$template "menu"} {$template "menu"}
<div v-if="!reverseProxyRef.isOn">
<div class="margin"></div> <div class="margin"></div>
<form class="ui form" data-tea-action="$" data-tea-success="success"> <p class="ui message warning">当前代理服务没有开启,可以通过点击 <a :href="'/servers/server/settings/reverseProxy/setting?serverId=' + serverId">[更多设置]</a> 开启 。</p>
<input type="hidden" name="serverId" :value="serverId"/>
<input type="hidden" name="reverseProxyRefJSON" :value="JSON.stringify(reverseProxyRef)"/>
<reverse-proxy-box :v-reverse-proxy-ref="reverseProxyRef"></reverse-proxy-box>
<submit-btn></submit-btn>
</form>
<div v-if="reverseProxyRef.isOn">
<div class="ui divider"></div>
<origin-list-box :v-primary-origins="primaryOrigins" :v-backup-origins="backupOrigins" :v-server-type="serverType"
:v-params="'type=server&serverId=' + serverId + '&reverseProxyId=' + reverseProxyConfig.id"></origin-list-box>
</div> </div>
<origin-list-box :v-primary-origins="primaryOrigins" :v-backup-origins="backupOrigins"
:v-server-type="serverType"
:v-params="'type=server&serverId=' + serverId + '&reverseProxyId=' + reverseProxyConfig.id"></origin-list-box>
</div> </div>

View File

@@ -1,17 +0,0 @@
Tea.context(function () {
this.success = NotifyReloadSuccess("保存成功")
this.updateOn = function (b) {
teaweb.confirm(b ? "确定要启用反向代理服务吗?" : "确定要停用反向代理服务吗?", function () {
this.$post(".updateOn")
.params({
"serverId": this.serverId,
"isOn": b ? 1 : 0,
"reverseProxyId": this.reverseProxyId
})
.success(function () {
window.location.reload()
})
})
}
})

View File

@@ -0,0 +1,14 @@
{$layout}
{$template "/left_menu"}
<div class="right-box">
{$template "menu"}
<div class="margin"></div>
<form class="ui form" data-tea-action="$" data-tea-success="success">
<input type="hidden" name="serverId" :value="serverId"/>
<input type="hidden" name="reverseProxyRefJSON" :value="JSON.stringify(reverseProxyRef)"/>
<reverse-proxy-box :v-reverse-proxy-ref="reverseProxyRef" :v-reverse-proxy-config="reverseProxyConfig"></reverse-proxy-box>
<submit-btn></submit-btn>
</form>
</div>

View File

@@ -0,0 +1,3 @@
Tea.context(function () {
this.success = NotifyReloadSuccess("保存成功")
})