From 7a45db71d56115845fd2c827b9ee5f0bbbd90911 Mon Sep 17 00:00:00 2001 From: zhengkunwang <31820853+zhengkunwang223@users.noreply.github.com> Date: Mon, 29 Jan 2024 16:34:32 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=20Node.js=20=E8=BF=90?= =?UTF-8?q?=E8=A1=8C=E7=8E=AF=E5=A2=83=E7=BD=91=E7=AB=99=E5=81=9C=E6=AD=A2?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98=20(#3734)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/service/website_utils.go | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/backend/app/service/website_utils.go b/backend/app/service/website_utils.go index 6a20a0e33..cd1b87a2c 100644 --- a/backend/app/service/website_utils.go +++ b/backend/app/service/website_utils.go @@ -556,7 +556,15 @@ func opWebsite(website *model.Website, operate string) error { case constant.Deployment: server.RemoveDirective("location", []string{"/"}) case constant.Runtime: - server.RemoveDirective("location", []string{"~", "[^/]\\.php(/|$)"}) + runtime, err := runtimeRepo.GetFirst(commonRepo.WithByID(website.RuntimeID)) + if err != nil { + return err + } + if runtime.Type == constant.RuntimePHP { + server.RemoveDirective("location", []string{"~", "[^/]\\.php(/|$)"}) + } else { + server.RemoveDirective("location", []string{"/"}) + } } server.UpdateRoot("/usr/share/nginx/html/stop") website.Status = constant.WebStopped @@ -594,10 +602,19 @@ func opWebsite(website *model.Website, operate string) error { case constant.Runtime: server.UpdateRoot(rootIndex) localPath := "" - if website.ProxyType == constant.RuntimeProxyUnix { - localPath = path.Join(nginxInstall.Install.GetPath(), rootIndex, "index.php") + runtime, err := runtimeRepo.GetFirst(commonRepo.WithByID(website.RuntimeID)) + if err != nil { + return err + } + if runtime.Type == constant.RuntimePHP { + if website.ProxyType == constant.RuntimeProxyUnix { + localPath = path.Join(nginxInstall.Install.GetPath(), rootIndex, "index.php") + } + server.UpdatePHPProxy([]string{website.Proxy}, localPath) + } else { + proxy := fmt.Sprintf("http://127.0.0.1:%d", runtime.Port) + server.UpdateRootProxy([]string{proxy}) } - server.UpdatePHPProxy([]string{website.Proxy}, localPath) } website.Status = constant.WebRunning now := time.Now()