summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go
diff options
context:
space:
mode:
authorManuel Dalla Lana <manuel@dallalana.it>2020-07-20 20:16:13 +0200
committerGitHub <noreply@github.com>2020-07-20 12:16:13 -0600
commit2ae8c119279826ef81223e3b2155a08779f3ee8b (patch)
tree3f3979d14e341bba975323cd48a885f3ad0223e7 /modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go
parente9b1d7dcb4cbf85da7fb4cf8c411a4f840a98cf1 (diff)
fastcgi: Add resolve_root_symlink (#3587)
Diffstat (limited to 'modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go')
-rw-r--r--modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go b/modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go
index 8c03172..de6d0a4 100644
--- a/modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go
+++ b/modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go
@@ -54,6 +54,14 @@ type Transport struct {
// that 404s if the fastcgi path info is not found.
SplitPath []string `json:"split_path,omitempty"`
+ // Path declared as root directory will be resolved to its absolute value
+ // after the evaluation of any symbolic links.
+ // Due to the nature of PHP opcache, root directory path is cached: when
+ // using a symlinked directory as root this could generate errors when
+ // symlink is changed without php-fpm being restarted; enabling this
+ // directive will set $_SERVER['DOCUMENT_ROOT'] to the real directory path.
+ ResolveRootSymlink bool `json:"resolve_root_symlink,omitempty"`
+
// Extra environment variables.
EnvVars map[string]string `json:"env,omitempty"`
@@ -179,6 +187,13 @@ func (t Transport) buildEnv(r *http.Request) (map[string]string, error) {
return nil, err
}
+ if t.ResolveRootSymlink {
+ root, err = filepath.EvalSymlinks(root)
+ if err != nil {
+ return nil, err
+ }
+ }
+
fpath := r.URL.Path
// split "actual path" from "path info" if configured