From e45d854634bfe958959b13346e4f65046b46112d Mon Sep 17 00:00:00 2001 From: HynoR <20227709+HynoR@users.noreply.github.com> Date: Thu, 7 Aug 2025 18:19:16 +0800 Subject: [PATCH] fix: improve location retrieval in OperateProxy to handle modified nginx configs --- agent/app/service/website.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/agent/app/service/website.go b/agent/app/service/website.go index 7f5f31dc4666..5e6500c8fd38 100644 --- a/agent/app/service/website.go +++ b/agent/app/service/website.go @@ -1632,9 +1632,16 @@ func (w WebsiteService) OperateProxy(req request.WebsiteProxyConfig) (err error) config.FilePath = includePath directives := config.Directives - location, ok := directives[0].(*components.Location) - if !ok { - err = errors.New("error") + + var location *components.Location + for _, directive := range directives { + if loc, ok := directive.(*components.Location); ok { + location = loc + break + } + } + if location == nil { + err = errors.New("invalid proxy config, no location found") return } location.UpdateDirective("proxy_pass", []string{req.ProxyPass})