From 2ff7726442ec68945595e31c42f8d2aea69c6373 Mon Sep 17 00:00:00 2001 From: zhengkunwang223 <31820853+zhengkunwang223@users.noreply.github.com> Date: Thu, 29 Jun 2023 18:42:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E9=98=B2=E7=9B=97?= =?UTF-8?q?=E9=93=BE=E4=BF=9D=E5=AD=98=E4=B8=A4=E6=AC=A1=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E8=AE=BF=E9=97=AE=E7=BD=91=E7=AB=99=E8=87=AA=E5=8A=A8=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E6=96=87=E4=BB=B6=E7=9A=84=E9=97=AE=E9=A2=98=20(#1489?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refs https://github.com/1Panel-dev/1Panel/issues/1460 --- backend/utils/nginx/components/server.go | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/backend/utils/nginx/components/server.go b/backend/utils/nginx/components/server.go index 2d53d081d..b88350300 100644 --- a/backend/utils/nginx/components/server.go +++ b/backend/utils/nginx/components/server.go @@ -127,13 +127,27 @@ func (s *Server) RemoveDirective(key string, params []string) { var newDirectives []IDirective for _, dir := range directives { if dir.GetName() == key { - if len(params) > 0 { - oldParams := dir.GetParameters() + if len(params) == 0 { + continue + } + oldParams := dir.GetParameters() + if key == "location" { + if len(params) == len(oldParams) { + exist := true + for i := range params { + if params[i] != oldParams[i] { + exist = false + break + } + } + if exist { + continue + } + } + } else { if oldParams[0] == params[0] { continue } - } else { - continue } } newDirectives = append(newDirectives, dir)