feat: 增加配置 php 配置文件功能

This commit is contained in:
zhengkunwang223
2023-04-04 18:54:04 +08:00
committed by zhengkunwang223
parent c629fa9575
commit 04a76fd94d
19 changed files with 295 additions and 46 deletions

View File

@@ -237,7 +237,7 @@ func (s *Server) UpdateRootProxy(proxy []string) {
s.UpdateDirectiveBySecondKey("location", "/", newDir)
}
func (s *Server) UpdatePHPProxy(proxy []string) {
func (s *Server) UpdatePHPProxy(proxy []string, localPath string) {
newDir := Directive{
Name: "location",
Parameters: []string{"~ [^/]\\.php(/|$)"},
@@ -256,6 +256,17 @@ func (s *Server) UpdatePHPProxy(proxy []string) {
Name: "include",
Parameters: []string{"fastcgi_params"},
})
if localPath == "" {
block.Directives = append(block.Directives, &Directive{
Name: "fastcgi_param",
Parameters: []string{"SCRIPT_FILENAME", "$document_root$fastcgi_script_name"},
})
} else {
block.Directives = append(block.Directives, &Directive{
Name: "fastcgi_param",
Parameters: []string{"SCRIPT_FILENAME", localPath},
})
}
newDir.Block = block
s.UpdateDirectiveBySecondKey("location", "~ [^/]\\.php(/|$)", newDir)
}