mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-06 23:00:25 +08:00
反向代理源站可以设置权重
This commit is contained in:
@@ -3,6 +3,7 @@ package origins
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
|
||||||
"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"
|
||||||
@@ -39,6 +40,7 @@ func (this *AddPopupAction) RunPost(params struct {
|
|||||||
OriginType string
|
OriginType string
|
||||||
|
|
||||||
ReverseProxyId int64
|
ReverseProxyId int64
|
||||||
|
Weight int32
|
||||||
Protocol string
|
Protocol string
|
||||||
Addr string
|
Addr string
|
||||||
|
|
||||||
@@ -56,7 +58,7 @@ func (this *AddPopupAction) RunPost(params struct {
|
|||||||
host := addr[:portIndex]
|
host := addr[:portIndex]
|
||||||
port := addr[portIndex+1:]
|
port := addr[portIndex+1:]
|
||||||
|
|
||||||
resp, err := this.RPC().OriginRPC().CreateOrigin(this.AdminContext(), &pb.CreateOriginRequest{
|
createResp, err := this.RPC().OriginRPC().CreateOrigin(this.AdminContext(), &pb.CreateOriginRequest{
|
||||||
Name: "",
|
Name: "",
|
||||||
Addr: &pb.NetworkAddress{
|
Addr: &pb.NetworkAddress{
|
||||||
Protocol: params.Protocol,
|
Protocol: params.Protocol,
|
||||||
@@ -64,12 +66,13 @@ func (this *AddPopupAction) RunPost(params struct {
|
|||||||
PortRange: port,
|
PortRange: port,
|
||||||
},
|
},
|
||||||
Description: "",
|
Description: "",
|
||||||
|
Weight: params.Weight,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
originId := resp.OriginId
|
originId := createResp.OriginId
|
||||||
originRef := &serverconfigs.OriginRef{
|
originRef := &serverconfigs.OriginRef{
|
||||||
IsOn: true,
|
IsOn: true,
|
||||||
OriginId: originId,
|
OriginId: originId,
|
||||||
@@ -128,5 +131,8 @@ func (this *AddPopupAction) RunPost(params struct {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 日志
|
||||||
|
this.CreateLog(oplogs.LevelInfo, "为反向代理服务 %d 添加源站 %d", params.ReverseProxyId, originId)
|
||||||
|
|
||||||
this.Success()
|
this.Success()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package origins
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
|
||||||
"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"
|
||||||
@@ -81,5 +82,8 @@ func (this *DeleteAction) RunPost(params struct {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 日志
|
||||||
|
this.CreateLog(oplogs.LevelInfo, "删除反向代理服务 %d 的源站 %d", params.ReverseProxyId, params.OriginId)
|
||||||
|
|
||||||
this.Success()
|
this.Success()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package origins
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
|
||||||
"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"
|
||||||
@@ -57,6 +58,7 @@ func (this *UpdatePopupAction) RunGet(params struct {
|
|||||||
"id": config.Id,
|
"id": config.Id,
|
||||||
"protocol": config.Addr.Protocol,
|
"protocol": config.Addr.Protocol,
|
||||||
"addr": config.Addr.Host + ":" + config.Addr.PortRange,
|
"addr": config.Addr.Host + ":" + config.Addr.PortRange,
|
||||||
|
"weight": config.Weight,
|
||||||
}
|
}
|
||||||
|
|
||||||
this.Show()
|
this.Show()
|
||||||
@@ -69,6 +71,7 @@ func (this *UpdatePopupAction) RunPost(params struct {
|
|||||||
ReverseProxyId int64
|
ReverseProxyId int64
|
||||||
Protocol string
|
Protocol string
|
||||||
Addr string
|
Addr string
|
||||||
|
Weight int32
|
||||||
|
|
||||||
Must *actions.Must
|
Must *actions.Must
|
||||||
}) {
|
}) {
|
||||||
@@ -93,11 +96,15 @@ func (this *UpdatePopupAction) RunPost(params struct {
|
|||||||
PortRange: port,
|
PortRange: port,
|
||||||
},
|
},
|
||||||
Description: "",
|
Description: "",
|
||||||
|
Weight: params.Weight,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 日志
|
||||||
|
this.CreateLog(oplogs.LevelInfo, "修改反向代理服务 %d 的源站 %d", params.ReverseProxyId, params.OriginId)
|
||||||
|
|
||||||
this.Success()
|
this.Success()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ Vue.component("origin-list-box", {
|
|||||||
methods: {
|
methods: {
|
||||||
createPrimaryOrigin: function () {
|
createPrimaryOrigin: function () {
|
||||||
teaweb.popup("/servers/server/settings/origins/addPopup?originType=primary&" + this.vParams, {
|
teaweb.popup("/servers/server/settings/origins/addPopup?originType=primary&" + this.vParams, {
|
||||||
|
height: "22em",
|
||||||
callback: function (resp) {
|
callback: function (resp) {
|
||||||
window.location.reload()
|
window.location.reload()
|
||||||
}
|
}
|
||||||
@@ -16,6 +17,7 @@ Vue.component("origin-list-box", {
|
|||||||
},
|
},
|
||||||
createBackupOrigin: function () {
|
createBackupOrigin: function () {
|
||||||
teaweb.popup("/servers/server/settings/origins/addPopup?originType=backup&" + this.vParams, {
|
teaweb.popup("/servers/server/settings/origins/addPopup?originType=backup&" + this.vParams, {
|
||||||
|
height: "22em",
|
||||||
callback: function (resp) {
|
callback: function (resp) {
|
||||||
window.location.reload()
|
window.location.reload()
|
||||||
}
|
}
|
||||||
@@ -23,6 +25,7 @@ Vue.component("origin-list-box", {
|
|||||||
},
|
},
|
||||||
updateOrigin: function (originId, originType) {
|
updateOrigin: function (originId, originType) {
|
||||||
teaweb.popup("/servers/server/settings/origins/updatePopup?originType=" + originType + "&" + this.vParams + "&originId=" + originId, {
|
teaweb.popup("/servers/server/settings/origins/updatePopup?originType=" + originType + "&" + this.vParams + "&originId=" + originId, {
|
||||||
|
height: "22em",
|
||||||
callback: function (resp) {
|
callback: function (resp) {
|
||||||
window.location.reload()
|
window.location.reload()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,13 @@
|
|||||||
<p class="comment">源站服务器地址,通常是一个IP(或域名)加端口<span v-if="serverType == 'httpProxy'">,不需要加 http:// 或 https://</span>。</p>
|
<p class="comment">源站服务器地址,通常是一个IP(或域名)加端口<span v-if="serverType == 'httpProxy'">,不需要加 http:// 或 https://</span>。</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>权重</td>
|
||||||
|
<td>
|
||||||
|
<input type="text" name="weight" maxlength="4" value="10" style="width:5em"/>
|
||||||
|
<p class="comment">数字越大,代表分配的请求比例越多。</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<submit-btn></submit-btn>
|
<submit-btn></submit-btn>
|
||||||
</form>
|
</form>
|
||||||
@@ -31,6 +31,13 @@
|
|||||||
<p class="comment">源站服务器地址,通常是一个IP(或域名)加端口<span v-if="serverType == 'httpProxy'">,不需要加 http:// 或 https://</span>。</p>
|
<p class="comment">源站服务器地址,通常是一个IP(或域名)加端口<span v-if="serverType == 'httpProxy'">,不需要加 http:// 或 https://</span>。</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>权重</td>
|
||||||
|
<td>
|
||||||
|
<input type="text" name="weight" maxlength="4" v-model="origin.weight" style="width:5em"/>
|
||||||
|
<p class="comment">数字越大,代表分配的请求比例越多。</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<submit-btn></submit-btn>
|
<submit-btn></submit-btn>
|
||||||
</form>
|
</form>
|
||||||
Reference in New Issue
Block a user