diff options
author | Francis Lavoie <lavofr@gmail.com> | 2020-12-04 19:12:13 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-04 17:12:13 -0700 |
commit | 6e9ac248dd5c2f7a4cd4e37ff277a86c18085be6 (patch) | |
tree | a6c9da30da87e8cba6986f43c6483dadf4919e6f /modules/caddyhttp/reverseproxy/fastcgi | |
parent | 5643dc3fb9e84b1dc862aa96bc5474d06f36d9c4 (diff) |
fastcgi: Set PATH_INFO to file matcher remainder as fallback (#3739)
* fastcgi: Set PATH_INFO to file matcher remainder as fallback
* fastcgi: Avoid changing scriptName when not necessary
* Stylistic tweaks
Co-authored-by: Matthew Holt <mholt@users.noreply.github.com>
Diffstat (limited to 'modules/caddyhttp/reverseproxy/fastcgi')
-rw-r--r-- | modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go b/modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go index de6d0a4..0976437 100644 --- a/modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go +++ b/modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go @@ -195,19 +195,27 @@ func (t Transport) buildEnv(r *http.Request) (map[string]string, error) { } fpath := r.URL.Path + scriptName := fpath + docURI := fpath // split "actual path" from "path info" if configured - var docURI, pathInfo string + var pathInfo string if splitPos := t.splitPos(fpath); splitPos > -1 { docURI = fpath[:splitPos] pathInfo = fpath[splitPos:] - } else { - docURI = fpath + + // Strip PATH_INFO from SCRIPT_NAME + scriptName = strings.TrimSuffix(scriptName, pathInfo) } - scriptName := fpath - // Strip PATH_INFO from SCRIPT_NAME - scriptName = strings.TrimSuffix(scriptName, pathInfo) + // Try to grab the path remainder from a file matcher + // if we didn't get a split result here. + // See https://github.com/caddyserver/caddy/issues/3718 + if pathInfo == "" { + if remainder, ok := repl.GetString("http.matchers.file.remainder"); ok { + pathInfo = remainder + } + } // SCRIPT_FILENAME is the absolute path of SCRIPT_NAME scriptFilename := filepath.Join(root, scriptName) |