diff --git a/agent/app/service/website.go b/agent/app/service/website.go index 7f5f31dc4..5e6500c8f 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})