mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-03 15:00:27 +08:00
反向代理增加是否重试50X选项,默认为启用
This commit is contained in:
@@ -12,5 +12,5 @@ dbs:
|
||||
|
||||
|
||||
fields:
|
||||
bool: [ "uamIsOn", "followPort", "requestHostExcludingPort", "autoRemoteStart", "autoInstallNftables", "enableIPLists", "detectAgents", "checkingPorts", "enableRecordHealthCheck", "offlineIsNotified", "http2Enabled", "http3Enabled" ]
|
||||
bool: [ "uamIsOn", "followPort", "requestHostExcludingPort", "autoRemoteStart", "autoInstallNftables", "enableIPLists", "detectAgents", "checkingPorts", "enableRecordHealthCheck", "offlineIsNotified", "http2Enabled", "http3Enabled", "enableHTTP2", "retry50X" ]
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ func (this *ReverseProxyDAO) ComposeReverseProxyConfig(tx *dbs.Tx, reverseProxyI
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
var config = &serverconfigs.ReverseProxyConfig{}
|
||||
var config = serverconfigs.NewReverseProxyConfig()
|
||||
config.Id = int64(reverseProxy.Id)
|
||||
config.IsOn = reverseProxy.IsOn
|
||||
config.RequestHostType = types.Int8(reverseProxy.RequestHostType)
|
||||
@@ -109,6 +109,7 @@ func (this *ReverseProxyDAO) ComposeReverseProxyConfig(tx *dbs.Tx, reverseProxyI
|
||||
config.StripPrefix = reverseProxy.StripPrefix
|
||||
config.AutoFlush = reverseProxy.AutoFlush == 1
|
||||
config.FollowRedirects = reverseProxy.FollowRedirects == 1
|
||||
config.Retry50X = reverseProxy.Retry50X
|
||||
|
||||
var schedulingConfig = &serverconfigs.SchedulingConfig{}
|
||||
if IsNotNull(reverseProxy.Scheduling) {
|
||||
@@ -218,6 +219,7 @@ func (this *ReverseProxyDAO) CreateReverseProxy(tx *dbs.Tx, adminId int64, userI
|
||||
op.AdminId = adminId
|
||||
op.UserId = userId
|
||||
op.RequestHostType = serverconfigs.RequestHostTypeProxyServer
|
||||
op.Retry50X = true
|
||||
|
||||
defaultHeaders := []string{"X-Real-IP", "X-Forwarded-For", "X-Forwarded-By", "X-Forwarded-Host", "X-Forwarded-Proto"}
|
||||
defaultHeadersJSON, err := json.Marshal(defaultHeaders)
|
||||
@@ -425,7 +427,8 @@ func (this *ReverseProxyDAO) UpdateReverseProxy(tx *dbs.Tx,
|
||||
maxConns int32,
|
||||
maxIdleConns int32,
|
||||
proxyProtocolJSON []byte,
|
||||
followRedirects bool) error {
|
||||
followRedirects bool,
|
||||
retry50X bool) error {
|
||||
if reverseProxyId <= 0 {
|
||||
return errors.New("invalid reverseProxyId")
|
||||
}
|
||||
@@ -490,6 +493,8 @@ func (this *ReverseProxyDAO) UpdateReverseProxy(tx *dbs.Tx,
|
||||
op.ProxyProtocol = proxyProtocolJSON
|
||||
}
|
||||
|
||||
op.Retry50X = retry50X
|
||||
|
||||
err = this.Save(tx, op)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -2,6 +2,34 @@ package models
|
||||
|
||||
import "github.com/iwind/TeaGo/dbs"
|
||||
|
||||
const (
|
||||
ReverseProxyField_Id dbs.FieldName = "id" // ID
|
||||
ReverseProxyField_AdminId dbs.FieldName = "adminId" // 管理员ID
|
||||
ReverseProxyField_UserId dbs.FieldName = "userId" // 用户ID
|
||||
ReverseProxyField_TemplateId dbs.FieldName = "templateId" // 模版ID
|
||||
ReverseProxyField_IsOn dbs.FieldName = "isOn" // 是否启用
|
||||
ReverseProxyField_Scheduling dbs.FieldName = "scheduling" // 调度算法
|
||||
ReverseProxyField_PrimaryOrigins dbs.FieldName = "primaryOrigins" // 主要源站
|
||||
ReverseProxyField_BackupOrigins dbs.FieldName = "backupOrigins" // 备用源站
|
||||
ReverseProxyField_StripPrefix dbs.FieldName = "stripPrefix" // 去除URL前缀
|
||||
ReverseProxyField_RequestHostType dbs.FieldName = "requestHostType" // 请求Host类型
|
||||
ReverseProxyField_RequestHost dbs.FieldName = "requestHost" // 请求Host
|
||||
ReverseProxyField_RequestHostExcludingPort dbs.FieldName = "requestHostExcludingPort" // 移除请求Host中的域名
|
||||
ReverseProxyField_RequestURI dbs.FieldName = "requestURI" // 请求URI
|
||||
ReverseProxyField_AutoFlush dbs.FieldName = "autoFlush" // 是否自动刷新缓冲区
|
||||
ReverseProxyField_AddHeaders dbs.FieldName = "addHeaders" // 自动添加的Header列表
|
||||
ReverseProxyField_State dbs.FieldName = "state" // 状态
|
||||
ReverseProxyField_CreatedAt dbs.FieldName = "createdAt" // 创建时间
|
||||
ReverseProxyField_ConnTimeout dbs.FieldName = "connTimeout" // 连接超时时间
|
||||
ReverseProxyField_ReadTimeout dbs.FieldName = "readTimeout" // 读取超时时间
|
||||
ReverseProxyField_IdleTimeout dbs.FieldName = "idleTimeout" // 空闲超时时间
|
||||
ReverseProxyField_MaxConns dbs.FieldName = "maxConns" // 最大并发连接数
|
||||
ReverseProxyField_MaxIdleConns dbs.FieldName = "maxIdleConns" // 最大空闲连接数
|
||||
ReverseProxyField_ProxyProtocol dbs.FieldName = "proxyProtocol" // Proxy Protocol配置
|
||||
ReverseProxyField_FollowRedirects dbs.FieldName = "followRedirects" // 回源跟随
|
||||
ReverseProxyField_Retry50X dbs.FieldName = "retry50X" // 启用50X重试
|
||||
)
|
||||
|
||||
// ReverseProxy 反向代理配置
|
||||
type ReverseProxy struct {
|
||||
Id uint32 `field:"id"` // ID
|
||||
@@ -28,33 +56,35 @@ type ReverseProxy struct {
|
||||
MaxIdleConns uint32 `field:"maxIdleConns"` // 最大空闲连接数
|
||||
ProxyProtocol dbs.JSON `field:"proxyProtocol"` // Proxy Protocol配置
|
||||
FollowRedirects uint8 `field:"followRedirects"` // 回源跟随
|
||||
Retry50X bool `field:"retry50X"` // 启用50X重试
|
||||
}
|
||||
|
||||
type ReverseProxyOperator struct {
|
||||
Id interface{} // ID
|
||||
AdminId interface{} // 管理员ID
|
||||
UserId interface{} // 用户ID
|
||||
TemplateId interface{} // 模版ID
|
||||
IsOn interface{} // 是否启用
|
||||
Scheduling interface{} // 调度算法
|
||||
PrimaryOrigins interface{} // 主要源站
|
||||
BackupOrigins interface{} // 备用源站
|
||||
StripPrefix interface{} // 去除URL前缀
|
||||
RequestHostType interface{} // 请求Host类型
|
||||
RequestHost interface{} // 请求Host
|
||||
RequestHostExcludingPort interface{} // 移除请求Host中的域名
|
||||
RequestURI interface{} // 请求URI
|
||||
AutoFlush interface{} // 是否自动刷新缓冲区
|
||||
AddHeaders interface{} // 自动添加的Header列表
|
||||
State interface{} // 状态
|
||||
CreatedAt interface{} // 创建时间
|
||||
ConnTimeout interface{} // 连接超时时间
|
||||
ReadTimeout interface{} // 读取超时时间
|
||||
IdleTimeout interface{} // 空闲超时时间
|
||||
MaxConns interface{} // 最大并发连接数
|
||||
MaxIdleConns interface{} // 最大空闲连接数
|
||||
ProxyProtocol interface{} // Proxy Protocol配置
|
||||
FollowRedirects interface{} // 回源跟随
|
||||
Id any // ID
|
||||
AdminId any // 管理员ID
|
||||
UserId any // 用户ID
|
||||
TemplateId any // 模版ID
|
||||
IsOn any // 是否启用
|
||||
Scheduling any // 调度算法
|
||||
PrimaryOrigins any // 主要源站
|
||||
BackupOrigins any // 备用源站
|
||||
StripPrefix any // 去除URL前缀
|
||||
RequestHostType any // 请求Host类型
|
||||
RequestHost any // 请求Host
|
||||
RequestHostExcludingPort any // 移除请求Host中的域名
|
||||
RequestURI any // 请求URI
|
||||
AutoFlush any // 是否自动刷新缓冲区
|
||||
AddHeaders any // 自动添加的Header列表
|
||||
State any // 状态
|
||||
CreatedAt any // 创建时间
|
||||
ConnTimeout any // 连接超时时间
|
||||
ReadTimeout any // 读取超时时间
|
||||
IdleTimeout any // 空闲超时时间
|
||||
MaxConns any // 最大并发连接数
|
||||
MaxIdleConns any // 最大空闲连接数
|
||||
ProxyProtocol any // Proxy Protocol配置
|
||||
FollowRedirects any // 回源跟随
|
||||
Retry50X any // 启用50X重试
|
||||
}
|
||||
|
||||
func NewReverseProxyOperator() *ReverseProxyOperator {
|
||||
|
||||
@@ -216,7 +216,7 @@ func (this *ReverseProxyService) UpdateReverseProxy(ctx context.Context, req *pb
|
||||
}
|
||||
}
|
||||
|
||||
err = models.SharedReverseProxyDAO.UpdateReverseProxy(tx, req.ReverseProxyId, types.Int8(req.RequestHostType), req.RequestHost, req.RequestHostExcludingPort, req.RequestURI, req.StripPrefix, req.AutoFlush, req.AddHeaders, connTimeout, readTimeout, idleTimeout, req.MaxConns, req.MaxIdleConns, req.ProxyProtocolJSON, req.FollowRedirects)
|
||||
err = models.SharedReverseProxyDAO.UpdateReverseProxy(tx, req.ReverseProxyId, types.Int8(req.RequestHostType), req.RequestHost, req.RequestHostExcludingPort, req.RequestURI, req.StripPrefix, req.AutoFlush, req.AddHeaders, connTimeout, readTimeout, idleTimeout, req.MaxConns, req.MaxIdleConns, req.ProxyProtocolJSON, req.FollowRedirects, req.Retry50X)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -221314,7 +221314,7 @@
|
||||
"name": "edgeReverseProxies",
|
||||
"engine": "InnoDB",
|
||||
"charset": "utf8mb4_general_ci",
|
||||
"definition": "CREATE TABLE `edgeReverseProxies` (\n `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n `adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',\n `userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',\n `templateId` int(11) unsigned DEFAULT '0' COMMENT '模版ID',\n `isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',\n `scheduling` json DEFAULT NULL COMMENT '调度算法',\n `primaryOrigins` json DEFAULT NULL COMMENT '主要源站',\n `backupOrigins` json DEFAULT NULL COMMENT '备用源站',\n `stripPrefix` varchar(255) DEFAULT NULL COMMENT '去除URL前缀',\n `requestHostType` tinyint(1) unsigned DEFAULT '0' COMMENT '请求Host类型',\n `requestHost` varchar(255) DEFAULT NULL COMMENT '请求Host',\n `requestHostExcludingPort` tinyint(1) unsigned DEFAULT '0' COMMENT '移除请求Host中的域名',\n `requestURI` varchar(1024) DEFAULT NULL COMMENT '请求URI',\n `autoFlush` tinyint(1) unsigned DEFAULT '0' COMMENT '是否自动刷新缓冲区',\n `addHeaders` json DEFAULT NULL COMMENT '自动添加的Header列表',\n `state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',\n `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n `connTimeout` json DEFAULT NULL COMMENT '连接超时时间',\n `readTimeout` json DEFAULT NULL COMMENT '读取超时时间',\n `idleTimeout` json DEFAULT NULL COMMENT '空闲超时时间',\n `maxConns` int(11) unsigned DEFAULT '0' COMMENT '最大并发连接数',\n `maxIdleConns` int(11) unsigned DEFAULT '0' COMMENT '最大空闲连接数',\n `proxyProtocol` json DEFAULT NULL COMMENT 'Proxy Protocol配置',\n `followRedirects` tinyint(1) unsigned DEFAULT '0' COMMENT '回源跟随',\n PRIMARY KEY (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='反向代理配置'",
|
||||
"definition": "CREATE TABLE `edgeReverseProxies` (\n `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n `adminId` int(11) unsigned DEFAULT '0' COMMENT '管理员ID',\n `userId` int(11) unsigned DEFAULT '0' COMMENT '用户ID',\n `templateId` int(11) unsigned DEFAULT '0' COMMENT '模版ID',\n `isOn` tinyint(1) unsigned DEFAULT '1' COMMENT '是否启用',\n `scheduling` json DEFAULT NULL COMMENT '调度算法',\n `primaryOrigins` json DEFAULT NULL COMMENT '主要源站',\n `backupOrigins` json DEFAULT NULL COMMENT '备用源站',\n `stripPrefix` varchar(255) DEFAULT NULL COMMENT '去除URL前缀',\n `requestHostType` tinyint(1) unsigned DEFAULT '0' COMMENT '请求Host类型',\n `requestHost` varchar(255) DEFAULT NULL COMMENT '请求Host',\n `requestHostExcludingPort` tinyint(1) unsigned DEFAULT '0' COMMENT '移除请求Host中的域名',\n `requestURI` varchar(1024) DEFAULT NULL COMMENT '请求URI',\n `autoFlush` tinyint(1) unsigned DEFAULT '0' COMMENT '是否自动刷新缓冲区',\n `addHeaders` json DEFAULT NULL COMMENT '自动添加的Header列表',\n `state` tinyint(1) unsigned DEFAULT '1' COMMENT '状态',\n `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n `connTimeout` json DEFAULT NULL COMMENT '连接超时时间',\n `readTimeout` json DEFAULT NULL COMMENT '读取超时时间',\n `idleTimeout` json DEFAULT NULL COMMENT '空闲超时时间',\n `maxConns` int(11) unsigned DEFAULT '0' COMMENT '最大并发连接数',\n `maxIdleConns` int(11) unsigned DEFAULT '0' COMMENT '最大空闲连接数',\n `proxyProtocol` json DEFAULT NULL COMMENT 'Proxy Protocol配置',\n `followRedirects` tinyint(1) unsigned DEFAULT '0' COMMENT '回源跟随',\n `retry50X` tinyint(1) unsigned DEFAULT '1' COMMENT '启用50X重试',\n PRIMARY KEY (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='反向代理配置'",
|
||||
"fields": [
|
||||
{
|
||||
"name": "id",
|
||||
@@ -221411,6 +221411,10 @@
|
||||
{
|
||||
"name": "followRedirects",
|
||||
"definition": "tinyint(1) unsigned DEFAULT '0' COMMENT '回源跟随'"
|
||||
},
|
||||
{
|
||||
"name": "retry50X",
|
||||
"definition": "tinyint(1) unsigned DEFAULT '1' COMMENT '启用50X重试'"
|
||||
}
|
||||
],
|
||||
"indexes": [
|
||||
|
||||
Reference in New Issue
Block a user