Prevent Caddy-Rewrite-Original-URI being added as an HTTP ENV variable passed to FastCGI

part of fix for #1153
This commit is contained in:
Toby Allen 2016-10-14 21:09:02 +01:00
parent 3b68482f59
commit 845c2702b1

View file

@ -245,6 +245,7 @@ func (h Handler) buildEnv(r *http.Request, rule Rule, fpath string) (map[string]
env["PATH_TRANSLATED"] = filepath.Join(h.AbsRoot, pathInfo) // Info: http://www.oreilly.com/openbook/cgi/ch02_04.html
}
// Some web apps rely on knowing HTTPS or not
if r.TLS != nil {
env["HTTPS"] = "on"
@ -257,13 +258,19 @@ func (h Handler) buildEnv(r *http.Request, rule Rule, fpath string) (map[string]
env[envVar[0]] = replacer.Replace(envVar[1])
}
// Add all HTTP headers to env variables
// Add all HTTP headers (except Caddy-Rewrite-Original-URI ) to env variables
for field, val := range r.Header {
if strings.ToUpper(field) != strings.ToUpper(internalRewriteFieldName) {
header := strings.ToUpper(field)
header = headerNameReplacer.Replace(header)
env["HTTP_"+header] = strings.Join(val, ", ")
}
}
return env, nil
}