支持PROXY Protocol

This commit is contained in:
GoEdgeLab
2021-10-12 20:18:29 +08:00
parent 66f781ab21
commit bddd053e47
5 changed files with 111 additions and 34 deletions

View File

@@ -87,15 +87,26 @@ func (this *SettingAction) RunPost(params struct {
return
}
// PROXY Protocol
var proxyProtocolJSON = []byte{}
if reverseProxyConfig.ProxyProtocol != nil {
proxyProtocolJSON, err = json.Marshal(reverseProxyConfig.ProxyProtocol)
if err != nil {
this.ErrorPage(err)
return
}
}
// 设置反向代理相关信息
_, err = this.RPC().ReverseProxyRPC().UpdateReverseProxy(this.AdminContext(), &pb.UpdateReverseProxyRequest{
ReverseProxyId: reverseProxyConfig.Id,
RequestHostType: types.Int32(reverseProxyConfig.RequestHostType),
RequestHost: reverseProxyConfig.RequestHost,
RequestURI: reverseProxyConfig.RequestURI,
StripPrefix: reverseProxyConfig.StripPrefix,
AutoFlush: reverseProxyConfig.AutoFlush,
AddHeaders: reverseProxyConfig.AddHeaders,
ReverseProxyId: reverseProxyConfig.Id,
RequestHostType: types.Int32(reverseProxyConfig.RequestHostType),
RequestHost: reverseProxyConfig.RequestHost,
RequestURI: reverseProxyConfig.RequestURI,
StripPrefix: reverseProxyConfig.StripPrefix,
AutoFlush: reverseProxyConfig.AutoFlush,
AddHeaders: reverseProxyConfig.AddHeaders,
ProxyProtocolJSON: proxyProtocolJSON,
})
this.Success()

View File

@@ -87,15 +87,26 @@ func (this *SettingAction) RunPost(params struct {
return
}
// PROXY Protocol
var proxyProtocolJSON = []byte{}
if reverseProxyConfig.ProxyProtocol != nil {
proxyProtocolJSON, err = json.Marshal(reverseProxyConfig.ProxyProtocol)
if err != nil {
this.ErrorPage(err)
return
}
}
// 设置反向代理相关信息
_, err = this.RPC().ReverseProxyRPC().UpdateReverseProxy(this.AdminContext(), &pb.UpdateReverseProxyRequest{
ReverseProxyId: reverseProxyConfig.Id,
RequestHostType: types.Int32(reverseProxyConfig.RequestHostType),
RequestHost: reverseProxyConfig.RequestHost,
RequestURI: reverseProxyConfig.RequestURI,
StripPrefix: reverseProxyConfig.StripPrefix,
AutoFlush: reverseProxyConfig.AutoFlush,
AddHeaders: reverseProxyConfig.AddHeaders,
ReverseProxyId: reverseProxyConfig.Id,
RequestHostType: types.Int32(reverseProxyConfig.RequestHostType),
RequestHost: reverseProxyConfig.RequestHost,
RequestURI: reverseProxyConfig.RequestURI,
StripPrefix: reverseProxyConfig.StripPrefix,
AutoFlush: reverseProxyConfig.AutoFlush,
AddHeaders: reverseProxyConfig.AddHeaders,
ProxyProtocolJSON: proxyProtocolJSON,
})
this.Success()

View File

@@ -78,15 +78,26 @@ func (this *SettingAction) RunPost(params struct {
return
}
// PROXY Protocol
var proxyProtocolJSON = []byte{}
if reverseProxyConfig.ProxyProtocol != nil {
proxyProtocolJSON, err = json.Marshal(reverseProxyConfig.ProxyProtocol)
if err != nil {
this.ErrorPage(err)
return
}
}
// 设置反向代理相关信息
_, err = this.RPC().ReverseProxyRPC().UpdateReverseProxy(this.AdminContext(), &pb.UpdateReverseProxyRequest{
ReverseProxyId: reverseProxyConfig.Id,
RequestHostType: types.Int32(reverseProxyConfig.RequestHostType),
RequestHost: reverseProxyConfig.RequestHost,
RequestURI: reverseProxyConfig.RequestURI,
StripPrefix: reverseProxyConfig.StripPrefix,
AutoFlush: reverseProxyConfig.AutoFlush,
AddHeaders: reverseProxyConfig.AddHeaders,
ReverseProxyId: reverseProxyConfig.Id,
RequestHostType: types.Int32(reverseProxyConfig.RequestHostType),
RequestHost: reverseProxyConfig.RequestHost,
RequestURI: reverseProxyConfig.RequestURI,
StripPrefix: reverseProxyConfig.StripPrefix,
AutoFlush: reverseProxyConfig.AutoFlush,
AddHeaders: reverseProxyConfig.AddHeaders,
ProxyProtocolJSON: proxyProtocolJSON,
})
this.Success()

View File

@@ -106,20 +106,31 @@ func (this *SettingAction) RunPost(params struct {
return
}
// PROXY Protocol
var proxyProtocolJSON = []byte{}
if reverseProxyConfig.ProxyProtocol != nil {
proxyProtocolJSON, err = json.Marshal(reverseProxyConfig.ProxyProtocol)
if err != nil {
this.ErrorPage(err)
return
}
}
// 设置反向代理相关信息
_, err = this.RPC().ReverseProxyRPC().UpdateReverseProxy(this.AdminContext(), &pb.UpdateReverseProxyRequest{
ReverseProxyId: reverseProxyConfig.Id,
RequestHostType: types.Int32(reverseProxyConfig.RequestHostType),
RequestHost: reverseProxyConfig.RequestHost,
RequestURI: reverseProxyConfig.RequestURI,
StripPrefix: reverseProxyConfig.StripPrefix,
AutoFlush: reverseProxyConfig.AutoFlush,
AddHeaders: reverseProxyConfig.AddHeaders,
ConnTimeoutJSON: connTimeoutJSON,
ReadTimeoutJSON: readTimeoutJSON,
IdleTimeoutJSON: idleTimeoutJSON,
MaxConns: types.Int32(reverseProxyConfig.MaxConns),
MaxIdleConns: types.Int32(reverseProxyConfig.MaxIdleConns),
ReverseProxyId: reverseProxyConfig.Id,
RequestHostType: types.Int32(reverseProxyConfig.RequestHostType),
RequestHost: reverseProxyConfig.RequestHost,
RequestURI: reverseProxyConfig.RequestURI,
StripPrefix: reverseProxyConfig.StripPrefix,
AutoFlush: reverseProxyConfig.AutoFlush,
AddHeaders: reverseProxyConfig.AddHeaders,
ConnTimeoutJSON: connTimeoutJSON,
ReadTimeoutJSON: readTimeoutJSON,
IdleTimeoutJSON: idleTimeoutJSON,
MaxConns: types.Int32(reverseProxyConfig.MaxConns),
MaxIdleConns: types.Int32(reverseProxyConfig.MaxIdleConns),
ProxyProtocolJSON: proxyProtocolJSON,
})
if err != nil {
this.ErrorPage(err)