Skip to content

Commit

Permalink
feat: PHP 配置增加 pathinfo 配置 (#3269)
Browse files Browse the repository at this point in the history
Refs #3254
  • Loading branch information
zhengkunwang223 authored Dec 11, 2023
1 parent e48c224 commit 94a2d4b
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion backend/utils/nginx/components/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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$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{"SCRIPT_FILENAME", "$document_root$fastcgi_script_name"},
Parameters: []string{"PATH_INFO", "$path_info"},
})
} else {
block.Directives = append(block.Directives, &Directive{
Expand Down

0 comments on commit 94a2d4b

Please sign in to comment.