diff --git a/internal/db/models/http_location_dao.go b/internal/db/models/http_location_dao.go index 225faeb1..6c50f28b 100644 --- a/internal/db/models/http_location_dao.go +++ b/internal/db/models/http_location_dao.go @@ -118,6 +118,7 @@ func (this *HTTPLocationDAO) ComposeLocationConfig(locationId int64) (*servercon config.Name = location.Name config.Pattern = location.Pattern config.URLPrefix = location.UrlPrefix + config.IsBreak = location.IsBreak == 1 // web if location.WebId > 0 { diff --git a/internal/rpc/services/service_http_location.go b/internal/rpc/services/service_http_location.go index d5bd475f..b979331d 100644 --- a/internal/rpc/services/service_http_location.go +++ b/internal/rpc/services/service_http_location.go @@ -99,6 +99,14 @@ func (this *HTTPLocationService) FindAndInitHTTPLocationReverseProxyConfig(ctx c IsOn: false, ReverseProxyId: reverseProxyId, } + reverseProxyJSON, err := json.Marshal(reverseProxyRef) + if err != nil { + return nil, err + } + err = models.SharedHTTPLocationDAO.UpdateLocationReverseProxy(req.LocationId, reverseProxyJSON) + if err != nil { + return nil, err + } } reverseProxyConfig, err := models.SharedReverseProxyDAO.ComposeReverseProxyConfig(reverseProxyRef.ReverseProxyId) @@ -139,6 +147,10 @@ func (this *HTTPLocationService) FindAndInitHTTPLocationWebConfig(ctx context.Co if err != nil { return nil, err } + err = models.SharedHTTPLocationDAO.UpdateLocationWeb(req.LocationId, webId) + if err != nil { + return nil, err + } } config, err := models.SharedHTTPWebDAO.ComposeWebConfig(webId) @@ -153,3 +165,18 @@ func (this *HTTPLocationService) FindAndInitHTTPLocationWebConfig(ctx context.Co WebJSON: configJSON, }, nil } + +// 修改反向代理设置 +func (this *HTTPLocationService) UpdateHTTPLocationReverseProxy(ctx context.Context, req *pb.UpdateHTTPLocationReverseProxyRequest) (*pb.RPCUpdateSuccess, error) { + // 校验请求 + _, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin) + if err != nil { + return nil, err + } + + err = models.SharedHTTPLocationDAO.UpdateLocationReverseProxy(req.LocationId, req.ReverseProxyJSON) + if err != nil { + return nil, err + } + return rpcutils.RPCUpdateSuccess() +}