feat: PHP 配置增加 pathinfo 配置 (#3269)

Refs https://github.com/1Panel-dev/1Panel/issues/3254
pull/3281/head
zhengkunwang 2023-12-11 18:06:07 +08:00 committed by GitHub
parent e48c224c41
commit 94a2d4b475
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 30 additions and 1 deletions

View File

@ -281,9 +281,38 @@ func (s *Server) UpdatePHPProxy(proxy []string, localPath string) {
Parameters: []string{"fastcgi_params"},
})
if localPath == "" {
block.Directives = append(block.Directives, &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.Directives = append(block.Directives, ifDir)
block.Directives = append(block.Directives, &Directive{
Name: "fastcgi_param",
Parameters: []string{"SCRIPT_FILENAME", "$document_root$fastcgi_script_name"},
Parameters: []string{"SCRIPT_FILENAME", "$document_root$real_script_name"},
})
block.Directives = append(block.Directives, &Directive{
Name: "fastcgi_param",
Parameters: []string{"SCRIPT_NAME", "$real_script_name"},
})
block.Directives = append(block.Directives, &Directive{
Name: "fastcgi_param",
Parameters: []string{"PATH_INFO", "$path_info"},
})
} else {
block.Directives = append(block.Directives, &Directive{