反向代理支持RequestPath、RequestURI等

This commit is contained in:
刘祥超
2020-09-27 10:03:24 +08:00
parent c272658c73
commit cf609dad3f
4 changed files with 127 additions and 86 deletions

View File

@@ -499,17 +499,19 @@ func (x *UpdateReverseProxyBackupOriginsRequest) GetOriginsJSON() []byte {
} }
// 修改是否启用 // 修改是否启用
type UpdateReverseProxyIsOnRequest struct { type UpdateReverseProxyRequest struct {
state protoimpl.MessageState state protoimpl.MessageState
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
ReverseProxyId int64 `protobuf:"varint,1,opt,name=reverseProxyId,proto3" json:"reverseProxyId,omitempty"` ReverseProxyId int64 `protobuf:"varint,1,opt,name=reverseProxyId,proto3" json:"reverseProxyId,omitempty"`
IsOn bool `protobuf:"varint,2,opt,name=isOn,proto3" json:"isOn,omitempty"` RequestHost string `protobuf:"bytes,2,opt,name=requestHost,proto3" json:"requestHost,omitempty"`
RequestURI string `protobuf:"bytes,3,opt,name=requestURI,proto3" json:"requestURI,omitempty"`
StripPrefix string `protobuf:"bytes,4,opt,name=stripPrefix,proto3" json:"stripPrefix,omitempty"`
} }
func (x *UpdateReverseProxyIsOnRequest) Reset() { func (x *UpdateReverseProxyRequest) Reset() {
*x = UpdateReverseProxyIsOnRequest{} *x = UpdateReverseProxyRequest{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_service_reverse_proxy_proto_msgTypes[9] mi := &file_service_reverse_proxy_proto_msgTypes[9]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@@ -517,13 +519,13 @@ func (x *UpdateReverseProxyIsOnRequest) Reset() {
} }
} }
func (x *UpdateReverseProxyIsOnRequest) String() string { func (x *UpdateReverseProxyRequest) String() string {
return protoimpl.X.MessageStringOf(x) return protoimpl.X.MessageStringOf(x)
} }
func (*UpdateReverseProxyIsOnRequest) ProtoMessage() {} func (*UpdateReverseProxyRequest) ProtoMessage() {}
func (x *UpdateReverseProxyIsOnRequest) ProtoReflect() protoreflect.Message { func (x *UpdateReverseProxyRequest) ProtoReflect() protoreflect.Message {
mi := &file_service_reverse_proxy_proto_msgTypes[9] mi := &file_service_reverse_proxy_proto_msgTypes[9]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@@ -535,23 +537,37 @@ func (x *UpdateReverseProxyIsOnRequest) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x) return mi.MessageOf(x)
} }
// Deprecated: Use UpdateReverseProxyIsOnRequest.ProtoReflect.Descriptor instead. // Deprecated: Use UpdateReverseProxyRequest.ProtoReflect.Descriptor instead.
func (*UpdateReverseProxyIsOnRequest) Descriptor() ([]byte, []int) { func (*UpdateReverseProxyRequest) Descriptor() ([]byte, []int) {
return file_service_reverse_proxy_proto_rawDescGZIP(), []int{9} return file_service_reverse_proxy_proto_rawDescGZIP(), []int{9}
} }
func (x *UpdateReverseProxyIsOnRequest) GetReverseProxyId() int64 { func (x *UpdateReverseProxyRequest) GetReverseProxyId() int64 {
if x != nil { if x != nil {
return x.ReverseProxyId return x.ReverseProxyId
} }
return 0 return 0
} }
func (x *UpdateReverseProxyIsOnRequest) GetIsOn() bool { func (x *UpdateReverseProxyRequest) GetRequestHost() string {
if x != nil { if x != nil {
return x.IsOn return x.RequestHost
} }
return false return ""
}
func (x *UpdateReverseProxyRequest) GetRequestURI() string {
if x != nil {
return x.RequestURI
}
return ""
}
func (x *UpdateReverseProxyRequest) GetStripPrefix() string {
if x != nil {
return x.StripPrefix
}
return ""
} }
var File_service_reverse_proxy_proto protoreflect.FileDescriptor var File_service_reverse_proxy_proto protoreflect.FileDescriptor
@@ -619,58 +635,62 @@ var file_service_reverse_proxy_proto_rawDesc = []byte{
0x52, 0x0e, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x49, 0x64, 0x52, 0x0e, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x49, 0x64,
0x12, 0x20, 0x0a, 0x0b, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x18, 0x12, 0x20, 0x0a, 0x0b, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x18,
0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x73, 0x4a, 0x53, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x73, 0x4a, 0x53,
0x4f, 0x4e, 0x22, 0x5b, 0x0a, 0x1d, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x76, 0x65, 0x4f, 0x4e, 0x22, 0xa7, 0x01, 0x0a, 0x19, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x76,
0x72, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x49, 0x73, 0x4f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x72, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x65, 0x73, 0x74, 0x12, 0x26, 0x0a, 0x0e, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x50, 0x72, 0x12, 0x26, 0x0a, 0x0e, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x78, 0x79,
0x6f, 0x78, 0x79, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0e, 0x72, 0x65, 0x76, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0e, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73,
0x65, 0x72, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x69, 0x65, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x49, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x72, 0x65, 0x71, 0x75,
0x73, 0x4f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x69, 0x73, 0x4f, 0x6e, 0x32, 0x65, 0x73, 0x74, 0x48, 0x6f, 0x73, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x72,
0xc2, 0x05, 0x0a, 0x13, 0x52, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x48, 0x6f, 0x73, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x72, 0x65,
0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x53, 0x0a, 0x12, 0x63, 0x72, 0x65, 0x61, 0x74, 0x71, 0x75, 0x65, 0x73, 0x74, 0x55, 0x52, 0x49, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a,
0x65, 0x52, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x12, 0x1d, 0x2e, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x55, 0x52, 0x49, 0x12, 0x20, 0x0a, 0x0b, 0x73, 0x74,
0x70, 0x62, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x72, 0x69, 0x70, 0x50, 0x72, 0x65, 0x66, 0x69, 0x78, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52,
0x50, 0x72, 0x6f, 0x78, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x70, 0x0b, 0x73, 0x74, 0x72, 0x69, 0x70, 0x50, 0x72, 0x65, 0x66, 0x69, 0x78, 0x32, 0xba, 0x05, 0x0a,
0x62, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x50, 0x13, 0x52, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x53, 0x65, 0x72,
0x72, 0x6f, 0x78, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x62, 0x0a, 0x17, 0x76, 0x69, 0x63, 0x65, 0x12, 0x53, 0x0a, 0x12, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65,
0x66, 0x69, 0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x52, 0x65, 0x76, 0x65, 0x72, 0x76, 0x65, 0x72, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x12, 0x1d, 0x2e, 0x70, 0x62, 0x2e,
0x73, 0x65, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x12, 0x22, 0x2e, 0x70, 0x62, 0x2e, 0x46, 0x69, 0x6e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x50, 0x72, 0x6f,
0x78, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x70, 0x62, 0x2e, 0x43,
0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x78,
0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x62, 0x0a, 0x17, 0x66, 0x69, 0x6e,
0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x52, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x50, 0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x52, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x50,
0x72, 0x6f, 0x78, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x70, 0x62, 0x72, 0x6f, 0x78, 0x79, 0x12, 0x22, 0x2e, 0x70, 0x62, 0x2e, 0x46, 0x69, 0x6e, 0x64, 0x45, 0x6e,
0x2e, 0x46, 0x69, 0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x52, 0x65, 0x76, 0x65, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x52, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x78,
0x72, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x70, 0x62, 0x2e, 0x46, 0x69,
0x12, 0x74, 0x0a, 0x1d, 0x66, 0x69, 0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x52, 0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x52, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65,
0x50, 0x72, 0x6f, 0x78, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x74, 0x0a,
0x1d, 0x66, 0x69, 0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x52, 0x65, 0x76, 0x65,
0x72, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x28,
0x2e, 0x70, 0x62, 0x2e, 0x46, 0x69, 0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x52,
0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x43, 0x6f, 0x6e, 0x66, 0x69,
0x67, 0x12, 0x28, 0x2e, 0x70, 0x62, 0x2e, 0x46, 0x69, 0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, 0x2e, 0x70, 0x62, 0x2e, 0x46, 0x69,
0x65, 0x64, 0x52, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x43, 0x6f, 0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x52, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65,
0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, 0x2e, 0x70, 0x62, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x2e, 0x46, 0x69, 0x6e, 0x64, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x52, 0x65, 0x76, 0x65, 0x6e, 0x73, 0x65, 0x12, 0x5d, 0x0a, 0x1c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x76,
0x72, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x65, 0x72, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x5d, 0x0a, 0x1c, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x69, 0x6e, 0x67, 0x12, 0x27, 0x2e, 0x70, 0x62, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52,
0x52, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x53, 0x63, 0x68, 0x65, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x53, 0x63, 0x68, 0x65, 0x64,
0x64, 0x75, 0x6c, 0x69, 0x6e, 0x67, 0x12, 0x27, 0x2e, 0x70, 0x62, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x75, 0x6c, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x70,
0x74, 0x65, 0x52, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x53, 0x63, 0x62, 0x2e, 0x52, 0x50, 0x43, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x75, 0x63, 0x63, 0x65,
0x68, 0x65, 0x64, 0x75, 0x6c, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x73, 0x73, 0x12, 0x65, 0x0a, 0x20, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x76, 0x65,
0x14, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x50, 0x43, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x75, 0x72, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x50, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x4f,
0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x65, 0x0a, 0x20, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x73, 0x12, 0x2b, 0x2e, 0x70, 0x62, 0x2e, 0x55, 0x70, 0x64, 0x61,
0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x50, 0x72, 0x69, 0x6d, 0x61, 0x74, 0x65, 0x52, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x50, 0x72,
0x72, 0x79, 0x4f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x73, 0x12, 0x2b, 0x2e, 0x70, 0x62, 0x2e, 0x55, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x4f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75,
0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x78, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x50, 0x43, 0x55, 0x70, 0x64, 0x61,
0x79, 0x50, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x4f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x73, 0x52, 0x74, 0x65, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x63, 0x0a, 0x1f, 0x75, 0x70, 0x64,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x50, 0x43, 0x55, 0x61, 0x74, 0x65, 0x52, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x42,
0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x63, 0x0a, 0x1f, 0x61, 0x63, 0x6b, 0x75, 0x70, 0x4f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x73, 0x12, 0x2a, 0x2e, 0x70,
0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x62, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x50,
0x78, 0x79, 0x42, 0x61, 0x63, 0x6b, 0x75, 0x70, 0x4f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x73, 0x12, 0x72, 0x6f, 0x78, 0x79, 0x42, 0x61, 0x63, 0x6b, 0x75, 0x70, 0x4f, 0x72, 0x69, 0x67, 0x69, 0x6e,
0x2a, 0x2e, 0x70, 0x62, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x76, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x50,
0x73, 0x65, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x42, 0x61, 0x63, 0x6b, 0x75, 0x70, 0x4f, 0x72, 0x69, 0x43, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x49,
0x67, 0x69, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x70, 0x62, 0x0a, 0x12, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x50,
0x2e, 0x52, 0x50, 0x43, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x72, 0x6f, 0x78, 0x79, 0x12, 0x1d, 0x2e, 0x70, 0x62, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65,
0x73, 0x12, 0x51, 0x0a, 0x16, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x76, 0x65, 0x72, 0x52, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x52, 0x65, 0x71, 0x75,
0x73, 0x65, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x49, 0x73, 0x4f, 0x6e, 0x12, 0x21, 0x2e, 0x70, 0x62, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x50, 0x43, 0x55, 0x70, 0x64, 0x61,
0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x50, 0x72, 0x74, 0x65, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70,
0x6f, 0x78, 0x79, 0x49, 0x73, 0x4f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x2e, 0x70, 0x62, 0x2e, 0x52, 0x50, 0x43, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x75, 0x63,
0x63, 0x65, 0x73, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x33,
} }
var ( var (
@@ -696,7 +716,7 @@ var file_service_reverse_proxy_proto_goTypes = []interface{}{
(*UpdateReverseProxySchedulingRequest)(nil), // 6: pb.UpdateReverseProxySchedulingRequest (*UpdateReverseProxySchedulingRequest)(nil), // 6: pb.UpdateReverseProxySchedulingRequest
(*UpdateReverseProxyPrimaryOriginsRequest)(nil), // 7: pb.UpdateReverseProxyPrimaryOriginsRequest (*UpdateReverseProxyPrimaryOriginsRequest)(nil), // 7: pb.UpdateReverseProxyPrimaryOriginsRequest
(*UpdateReverseProxyBackupOriginsRequest)(nil), // 8: pb.UpdateReverseProxyBackupOriginsRequest (*UpdateReverseProxyBackupOriginsRequest)(nil), // 8: pb.UpdateReverseProxyBackupOriginsRequest
(*UpdateReverseProxyIsOnRequest)(nil), // 9: pb.UpdateReverseProxyIsOnRequest (*UpdateReverseProxyRequest)(nil), // 9: pb.UpdateReverseProxyRequest
(*ReverseProxy)(nil), // 10: pb.ReverseProxy (*ReverseProxy)(nil), // 10: pb.ReverseProxy
(*RPCUpdateSuccess)(nil), // 11: pb.RPCUpdateSuccess (*RPCUpdateSuccess)(nil), // 11: pb.RPCUpdateSuccess
} }
@@ -708,14 +728,14 @@ var file_service_reverse_proxy_proto_depIdxs = []int32{
6, // 4: pb.ReverseProxyService.updateReverseProxyScheduling:input_type -> pb.UpdateReverseProxySchedulingRequest 6, // 4: pb.ReverseProxyService.updateReverseProxyScheduling:input_type -> pb.UpdateReverseProxySchedulingRequest
7, // 5: pb.ReverseProxyService.updateReverseProxyPrimaryOrigins:input_type -> pb.UpdateReverseProxyPrimaryOriginsRequest 7, // 5: pb.ReverseProxyService.updateReverseProxyPrimaryOrigins:input_type -> pb.UpdateReverseProxyPrimaryOriginsRequest
8, // 6: pb.ReverseProxyService.updateReverseProxyBackupOrigins:input_type -> pb.UpdateReverseProxyBackupOriginsRequest 8, // 6: pb.ReverseProxyService.updateReverseProxyBackupOrigins:input_type -> pb.UpdateReverseProxyBackupOriginsRequest
9, // 7: pb.ReverseProxyService.updateReverseProxyIsOn:input_type -> pb.UpdateReverseProxyIsOnRequest 9, // 7: pb.ReverseProxyService.updateReverseProxy:input_type -> pb.UpdateReverseProxyRequest
1, // 8: pb.ReverseProxyService.createReverseProxy:output_type -> pb.CreateReverseProxyResponse 1, // 8: pb.ReverseProxyService.createReverseProxy:output_type -> pb.CreateReverseProxyResponse
3, // 9: pb.ReverseProxyService.findEnabledReverseProxy:output_type -> pb.FindEnabledReverseProxyResponse 3, // 9: pb.ReverseProxyService.findEnabledReverseProxy:output_type -> pb.FindEnabledReverseProxyResponse
5, // 10: pb.ReverseProxyService.findEnabledReverseProxyConfig:output_type -> pb.FindEnabledReverseProxyConfigResponse 5, // 10: pb.ReverseProxyService.findEnabledReverseProxyConfig:output_type -> pb.FindEnabledReverseProxyConfigResponse
11, // 11: pb.ReverseProxyService.updateReverseProxyScheduling:output_type -> pb.RPCUpdateSuccess 11, // 11: pb.ReverseProxyService.updateReverseProxyScheduling:output_type -> pb.RPCUpdateSuccess
11, // 12: pb.ReverseProxyService.updateReverseProxyPrimaryOrigins:output_type -> pb.RPCUpdateSuccess 11, // 12: pb.ReverseProxyService.updateReverseProxyPrimaryOrigins:output_type -> pb.RPCUpdateSuccess
11, // 13: pb.ReverseProxyService.updateReverseProxyBackupOrigins:output_type -> pb.RPCUpdateSuccess 11, // 13: pb.ReverseProxyService.updateReverseProxyBackupOrigins:output_type -> pb.RPCUpdateSuccess
11, // 14: pb.ReverseProxyService.updateReverseProxyIsOn:output_type -> pb.RPCUpdateSuccess 11, // 14: pb.ReverseProxyService.updateReverseProxy:output_type -> pb.RPCUpdateSuccess
8, // [8:15] is the sub-list for method output_type 8, // [8:15] is the sub-list for method output_type
1, // [1:8] is the sub-list for method input_type 1, // [1:8] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name 1, // [1:1] is the sub-list for extension type_name
@@ -840,7 +860,7 @@ func file_service_reverse_proxy_proto_init() {
} }
} }
file_service_reverse_proxy_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { file_service_reverse_proxy_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UpdateReverseProxyIsOnRequest); i { switch v := v.(*UpdateReverseProxyRequest); i {
case 0: case 0:
return &v.state return &v.state
case 1: case 1:
@@ -897,7 +917,7 @@ type ReverseProxyServiceClient interface {
// 修改备用源站信息 // 修改备用源站信息
UpdateReverseProxyBackupOrigins(ctx context.Context, in *UpdateReverseProxyBackupOriginsRequest, opts ...grpc.CallOption) (*RPCUpdateSuccess, error) UpdateReverseProxyBackupOrigins(ctx context.Context, in *UpdateReverseProxyBackupOriginsRequest, opts ...grpc.CallOption) (*RPCUpdateSuccess, error)
// 修改是否启用 // 修改是否启用
UpdateReverseProxyIsOn(ctx context.Context, in *UpdateReverseProxyIsOnRequest, opts ...grpc.CallOption) (*RPCUpdateSuccess, error) UpdateReverseProxy(ctx context.Context, in *UpdateReverseProxyRequest, opts ...grpc.CallOption) (*RPCUpdateSuccess, error)
} }
type reverseProxyServiceClient struct { type reverseProxyServiceClient struct {
@@ -962,9 +982,9 @@ func (c *reverseProxyServiceClient) UpdateReverseProxyBackupOrigins(ctx context.
return out, nil return out, nil
} }
func (c *reverseProxyServiceClient) UpdateReverseProxyIsOn(ctx context.Context, in *UpdateReverseProxyIsOnRequest, opts ...grpc.CallOption) (*RPCUpdateSuccess, error) { func (c *reverseProxyServiceClient) UpdateReverseProxy(ctx context.Context, in *UpdateReverseProxyRequest, opts ...grpc.CallOption) (*RPCUpdateSuccess, error) {
out := new(RPCUpdateSuccess) out := new(RPCUpdateSuccess)
err := c.cc.Invoke(ctx, "/pb.ReverseProxyService/updateReverseProxyIsOn", in, out, opts...) err := c.cc.Invoke(ctx, "/pb.ReverseProxyService/updateReverseProxy", in, out, opts...)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -986,7 +1006,7 @@ type ReverseProxyServiceServer interface {
// 修改备用源站信息 // 修改备用源站信息
UpdateReverseProxyBackupOrigins(context.Context, *UpdateReverseProxyBackupOriginsRequest) (*RPCUpdateSuccess, error) UpdateReverseProxyBackupOrigins(context.Context, *UpdateReverseProxyBackupOriginsRequest) (*RPCUpdateSuccess, error)
// 修改是否启用 // 修改是否启用
UpdateReverseProxyIsOn(context.Context, *UpdateReverseProxyIsOnRequest) (*RPCUpdateSuccess, error) UpdateReverseProxy(context.Context, *UpdateReverseProxyRequest) (*RPCUpdateSuccess, error)
} }
// UnimplementedReverseProxyServiceServer can be embedded to have forward compatible implementations. // UnimplementedReverseProxyServiceServer can be embedded to have forward compatible implementations.
@@ -1011,8 +1031,8 @@ func (*UnimplementedReverseProxyServiceServer) UpdateReverseProxyPrimaryOrigins(
func (*UnimplementedReverseProxyServiceServer) UpdateReverseProxyBackupOrigins(context.Context, *UpdateReverseProxyBackupOriginsRequest) (*RPCUpdateSuccess, error) { func (*UnimplementedReverseProxyServiceServer) UpdateReverseProxyBackupOrigins(context.Context, *UpdateReverseProxyBackupOriginsRequest) (*RPCUpdateSuccess, error) {
return nil, status.Errorf(codes.Unimplemented, "method UpdateReverseProxyBackupOrigins not implemented") return nil, status.Errorf(codes.Unimplemented, "method UpdateReverseProxyBackupOrigins not implemented")
} }
func (*UnimplementedReverseProxyServiceServer) UpdateReverseProxyIsOn(context.Context, *UpdateReverseProxyIsOnRequest) (*RPCUpdateSuccess, error) { func (*UnimplementedReverseProxyServiceServer) UpdateReverseProxy(context.Context, *UpdateReverseProxyRequest) (*RPCUpdateSuccess, error) {
return nil, status.Errorf(codes.Unimplemented, "method UpdateReverseProxyIsOn not implemented") return nil, status.Errorf(codes.Unimplemented, "method UpdateReverseProxy not implemented")
} }
func RegisterReverseProxyServiceServer(s *grpc.Server, srv ReverseProxyServiceServer) { func RegisterReverseProxyServiceServer(s *grpc.Server, srv ReverseProxyServiceServer) {
@@ -1127,20 +1147,20 @@ func _ReverseProxyService_UpdateReverseProxyBackupOrigins_Handler(srv interface{
return interceptor(ctx, in, info, handler) return interceptor(ctx, in, info, handler)
} }
func _ReverseProxyService_UpdateReverseProxyIsOn_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { func _ReverseProxyService_UpdateReverseProxy_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(UpdateReverseProxyIsOnRequest) in := new(UpdateReverseProxyRequest)
if err := dec(in); err != nil { if err := dec(in); err != nil {
return nil, err return nil, err
} }
if interceptor == nil { if interceptor == nil {
return srv.(ReverseProxyServiceServer).UpdateReverseProxyIsOn(ctx, in) return srv.(ReverseProxyServiceServer).UpdateReverseProxy(ctx, in)
} }
info := &grpc.UnaryServerInfo{ info := &grpc.UnaryServerInfo{
Server: srv, Server: srv,
FullMethod: "/pb.ReverseProxyService/UpdateReverseProxyIsOn", FullMethod: "/pb.ReverseProxyService/UpdateReverseProxy",
} }
handler := func(ctx context.Context, req interface{}) (interface{}, error) { handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ReverseProxyServiceServer).UpdateReverseProxyIsOn(ctx, req.(*UpdateReverseProxyIsOnRequest)) return srv.(ReverseProxyServiceServer).UpdateReverseProxy(ctx, req.(*UpdateReverseProxyRequest))
} }
return interceptor(ctx, in, info, handler) return interceptor(ctx, in, info, handler)
} }
@@ -1174,8 +1194,8 @@ var _ReverseProxyService_serviceDesc = grpc.ServiceDesc{
Handler: _ReverseProxyService_UpdateReverseProxyBackupOrigins_Handler, Handler: _ReverseProxyService_UpdateReverseProxyBackupOrigins_Handler,
}, },
{ {
MethodName: "updateReverseProxyIsOn", MethodName: "updateReverseProxy",
Handler: _ReverseProxyService_UpdateReverseProxyIsOn_Handler, Handler: _ReverseProxyService_UpdateReverseProxy_Handler,
}, },
}, },
Streams: []grpc.StreamDesc{}, Streams: []grpc.StreamDesc{},

View File

@@ -26,7 +26,7 @@ service ReverseProxyService {
rpc updateReverseProxyBackupOrigins (UpdateReverseProxyBackupOriginsRequest) returns (RPCUpdateSuccess); rpc updateReverseProxyBackupOrigins (UpdateReverseProxyBackupOriginsRequest) returns (RPCUpdateSuccess);
// 修改是否启用 // 修改是否启用
rpc updateReverseProxyIsOn (UpdateReverseProxyIsOnRequest) returns (RPCUpdateSuccess); rpc updateReverseProxy (UpdateReverseProxyRequest) returns (RPCUpdateSuccess);
} }
// 创建反向代理 // 创建反向代理
@@ -77,7 +77,9 @@ message UpdateReverseProxyBackupOriginsRequest {
} }
// 修改是否启用 // 修改是否启用
message UpdateReverseProxyIsOnRequest { message UpdateReverseProxyRequest {
int64 reverseProxyId = 1; int64 reverseProxyId = 1;
bool isOn = 2; string requestHost = 2;
string requestURI = 3;
string stripPrefix = 4;
} }

View File

@@ -8,7 +8,7 @@ type HTTPRootConfig struct {
IsOn bool `yaml:"isOn" json:"isOn"` // 是否启用 IsOn bool `yaml:"isOn" json:"isOn"` // 是否启用
Dir string `yaml:"dir" json:"dir"` // 目录 Dir string `yaml:"dir" json:"dir"` // 目录
Indexes []string `yaml:"indexes" json:"indexes"` // 默认首页文件 Indexes []string `yaml:"indexes" json:"indexes"` // 默认首页文件
StripPrefix string `yaml:"stripPrefix" json:"stripPrefix"` // 去除前缀 StripPrefix string `yaml:"stripPrefix" json:"stripPrefix"` // 去除URL前缀
DecodePath bool `yaml:"decodePath" json:"decodePath"` // 是否对请求路径进行解码 DecodePath bool `yaml:"decodePath" json:"decodePath"` // 是否对请求路径进行解码
IsBreak bool `yaml:"isBreak" json:"isBreak"` // 找不到文件的情况下是否终止 IsBreak bool `yaml:"isBreak" json:"isBreak"` // 找不到文件的情况下是否终止

View File

@@ -1,6 +1,7 @@
package serverconfigs package serverconfigs
import ( import (
"github.com/TeaOSLab/EdgeCommon/pkg/configutils"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/schedulingconfigs" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/schedulingconfigs"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
"sync" "sync"
@@ -16,7 +17,12 @@ type ReverseProxyConfig struct {
BackupOriginRefs []*OriginRef `yaml:"backupOriginRefs" json:"backupOriginRefs"` // 备用源站引用 BackupOriginRefs []*OriginRef `yaml:"backupOriginRefs" json:"backupOriginRefs"` // 备用源站引用
Scheduling *SchedulingConfig `yaml:"scheduling" json:"scheduling"` // 调度算法选项 Scheduling *SchedulingConfig `yaml:"scheduling" json:"scheduling"` // 调度算法选项
// TODO 可以设置同后端交互的主机名Host并支持变量 StripPrefix string `yaml:"stripPrefix" json:"stripPrefix"` // 去除URL前缀
RequestHost string `yaml:"requestHost" json:"requestHost"` // 请求Host支持变量
RequestURI string `yaml:"requestURI" json:"requestURI"` // 请求URI支持变量如果同时定义了StripPrefix则先执行StripPrefix
requestHostHasVariables bool
requestURIHasVariables bool
hasPrimaryOrigins bool hasPrimaryOrigins bool
hasBackupOrigins bool hasBackupOrigins bool
@@ -27,6 +33,9 @@ type ReverseProxyConfig struct {
// 初始化 // 初始化
func (this *ReverseProxyConfig) Init() error { func (this *ReverseProxyConfig) Init() error {
this.requestHostHasVariables = configutils.HasVariables(this.RequestHost)
this.requestURIHasVariables = configutils.HasVariables(this.RequestURI)
this.hasPrimaryOrigins = len(this.PrimaryOrigins) > 0 this.hasPrimaryOrigins = len(this.PrimaryOrigins) > 0
this.hasBackupOrigins = len(this.BackupOrigins) > 0 this.hasBackupOrigins = len(this.BackupOrigins) > 0
@@ -140,3 +149,13 @@ func (this *ReverseProxyConfig) FindSchedulingConfig() *SchedulingConfig {
} }
return this.Scheduling return this.Scheduling
} }
// 判断RequestHost是否有变量
func (this *ReverseProxyConfig) RequestHostHasVariables() bool {
return this.requestHostHasVariables
}
// 判断RequestURI是否有变量
func (this *ReverseProxyConfig) RequestURIHasVariables() bool {
return this.requestURIHasVariables
}