summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Holt <mholt@users.noreply.github.com>2020-03-23 21:12:54 -0600
committerGitHub <noreply@github.com>2020-03-23 21:12:54 -0600
commit2eede58b3a0f39d0cb0552eadaec02a0169835ac (patch)
treec00a9a6c5aa214aa38e8f7c5bb5956c89401dae4
parent235357abc80df710fe4c4ec21cf76d84cc664e17 (diff)
fastcgi: Ensure root is always absolute (issue #3178) (#3182)
-rw-r--r--modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go b/modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go
index 99bf5ec..11900c1 100644
--- a/modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go
+++ b/modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go
@@ -164,7 +164,12 @@ func (t Transport) buildEnv(r *http.Request) (map[string]string, error) {
ip = strings.Replace(ip, "[", "", 1)
ip = strings.Replace(ip, "]", "", 1)
- root := repl.ReplaceAll(t.Root, ".")
+ // make sure file root is absolute
+ root, err := filepath.Abs(repl.ReplaceAll(t.Root, "."))
+ if err != nil {
+ return nil, err
+ }
+
fpath := r.URL.Path
// Split path in preparation for env variables.