fix: improve location retrieval in OperateProxy to handle modified nginx configs (#9901)

This commit is contained in:
KOMATA 2025-08-07 21:49:57 +08:00 committed by GitHub
parent 04a0e15899
commit 39d3b819fb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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})