From 5bcbf328237f06483eeb17ca3aab3effd03bb06e Mon Sep 17 00:00:00 2001 From: ChengPlay <31820853+zhengkunwang223@users.noreply.github.com> Date: Tue, 22 Apr 2025 15:51:06 +0800 Subject: [PATCH] Fix issue with errors when reverse proxy source text includes comments. (#8444) Refs https://github.com/1Panel-dev/1Panel/issues/8442 --- backend/app/service/website.go | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/backend/app/service/website.go b/backend/app/service/website.go index bd3e2d9ea..f2aa84a7a 100644 --- a/backend/app/service/website.go +++ b/backend/app/service/website.go @@ -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 {