Fix issue with errors when reverse proxy source text includes comments. (#8444)
Some checks are pending
SonarCloud Scan / SonarCloud (push) Waiting to run

Refs https://github.com/1Panel-dev/1Panel/issues/8442
This commit is contained in:
ChengPlay 2025-04-22 15:51:06 +08:00 committed by GitHub
parent 0aa90e1b2d
commit 5bcbf32823
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1768,11 +1768,22 @@ func (w WebsiteService) GetProxies(id uint) (res []request.WebsiteProxyConfig, e
}
directives := config.GetDirectives()
location, ok := directives[0].(*components.Location)
if !ok {
err = errors.New("error")
return
var (
location *components.Location
ok bool
)
for _, directive := range directives {
if directive.GetName() == "location" {
location, ok = directive.(*components.Location)
if ok {
break
}
}
}
if location == nil {
return nil, buserr.New("ErrConfigParse")
}
proxyConfig.ProxyPass = location.ProxyPass
proxyConfig.Cache = location.Cache
if location.CacheTime > 0 {