From 036b4c9918dfd3c5ba7e87960c5411715a2cd6f4 Mon Sep 17 00:00:00 2001 From: zhengkunwang223 <1paneldev@sina.com> Date: Thu, 15 Jan 2026 14:57:00 +0800 Subject: [PATCH] feat: fix redirection issue caused by incorrect PHP PATH_INFO configuration --- .gitignore | 8 ++++++- agent/utils/nginx/components/server.go | 33 ++++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index b9787bf79278..5c105b380374 100644 --- a/.gitignore +++ b/.gitignore @@ -62,4 +62,10 @@ cmd/server/fileList.txt 1Panel.code-workspace core/.golangci.yml -agent/.golangci.yml \ No newline at end of file +agent/.golangci.yml + +.opencode +openspec +CLAUDE.md +AGENTS.md +opencode.json \ No newline at end of file diff --git a/agent/utils/nginx/components/server.go b/agent/utils/nginx/components/server.go index 84fe0b046df3..028a8ee8c18e 100644 --- a/agent/utils/nginx/components/server.go +++ b/agent/utils/nginx/components/server.go @@ -424,12 +424,41 @@ func (s *Server) UpdatePHPProxy(proxy []string, localPath string) { }, ) if localPath == "" { + block.AppendDirectives(&Directive{ + Name: "set", + Parameters: []string{"$real_script_name", "$fastcgi_script_name"}, + }) + ifDir := &Directive{ + Name: "if", + Parameters: []string{"($fastcgi_script_name ~ \"^(.+?\\.php)(/.+)$\")"}, + } + ifDir.Block = &Block{ + Directives: []IDirective{ + &Directive{ + Name: "set", + Parameters: []string{"$real_script_name", "$1"}, + }, + &Directive{ + Name: "set", + Parameters: []string{"$path_info", "$2"}, + }, + }, + } block.AppendDirectives( + ifDir, + &Directive{ + Name: "fastcgi_param", + Parameters: []string{"SCRIPT_FILENAME", "$document_root$real_script_name"}, + }, &Directive{ Name: "fastcgi_param", - Parameters: []string{"SCRIPT_FILENAME", "$document_root$fastcgi_script_name"}, + Parameters: []string{"SCRIPT_NAME", "$real_script_name"}, }, - ) + &Directive{ + Name: "fastcgi_param", + Parameters: []string{"PATH_INFO", "$path_info"}, + }) + } else { block.AppendDirectives(&Directive{ Name: "fastcgi_param",