summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/reverseproxy/fastcgi
diff options
context:
space:
mode:
Diffstat (limited to 'modules/caddyhttp/reverseproxy/fastcgi')
-rw-r--r--modules/caddyhttp/reverseproxy/fastcgi/caddyfile.go43
-rw-r--r--modules/caddyhttp/reverseproxy/fastcgi/client.go3
-rw-r--r--modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go16
3 files changed, 17 insertions, 45 deletions
diff --git a/modules/caddyhttp/reverseproxy/fastcgi/caddyfile.go b/modules/caddyhttp/reverseproxy/fastcgi/caddyfile.go
index 799050e..a24a3ed 100644
--- a/modules/caddyhttp/reverseproxy/fastcgi/caddyfile.go
+++ b/modules/caddyhttp/reverseproxy/fastcgi/caddyfile.go
@@ -217,25 +217,18 @@ func parsePHPFastCGI(h httpcaddyfile.Helper) ([]httpcaddyfile.ConfigValue, error
return nil, dispenser.ArgErr()
}
fcgiTransport.Root = dispenser.Val()
- dispenser.Delete()
- dispenser.Delete()
+ dispenser.DeleteN(2)
case "split":
extensions = dispenser.RemainingArgs()
- dispenser.Delete()
- for range extensions {
- dispenser.Delete()
- }
+ dispenser.DeleteN(len(extensions) + 1)
if len(extensions) == 0 {
return nil, dispenser.ArgErr()
}
case "env":
args := dispenser.RemainingArgs()
- dispenser.Delete()
- for range args {
- dispenser.Delete()
- }
+ dispenser.DeleteN(len(args) + 1)
if len(args) != 2 {
return nil, dispenser.ArgErr()
}
@@ -246,10 +239,7 @@ func parsePHPFastCGI(h httpcaddyfile.Helper) ([]httpcaddyfile.ConfigValue, error
case "index":
args := dispenser.RemainingArgs()
- dispenser.Delete()
- for range args {
- dispenser.Delete()
- }
+ dispenser.DeleteN(len(args) + 1)
if len(args) != 1 {
return nil, dispenser.ArgErr()
}
@@ -257,10 +247,7 @@ func parsePHPFastCGI(h httpcaddyfile.Helper) ([]httpcaddyfile.ConfigValue, error
case "try_files":
args := dispenser.RemainingArgs()
- dispenser.Delete()
- for range args {
- dispenser.Delete()
- }
+ dispenser.DeleteN(len(args) + 1)
if len(args) < 1 {
return nil, dispenser.ArgErr()
}
@@ -268,10 +255,7 @@ func parsePHPFastCGI(h httpcaddyfile.Helper) ([]httpcaddyfile.ConfigValue, error
case "resolve_root_symlink":
args := dispenser.RemainingArgs()
- dispenser.Delete()
- for range args {
- dispenser.Delete()
- }
+ dispenser.DeleteN(len(args) + 1)
fcgiTransport.ResolveRootSymlink = true
case "dial_timeout":
@@ -283,8 +267,7 @@ func parsePHPFastCGI(h httpcaddyfile.Helper) ([]httpcaddyfile.ConfigValue, error
return nil, dispenser.Errf("bad timeout value %s: %v", dispenser.Val(), err)
}
fcgiTransport.DialTimeout = caddy.Duration(dur)
- dispenser.Delete()
- dispenser.Delete()
+ dispenser.DeleteN(2)
case "read_timeout":
if !dispenser.NextArg() {
@@ -295,8 +278,7 @@ func parsePHPFastCGI(h httpcaddyfile.Helper) ([]httpcaddyfile.ConfigValue, error
return nil, dispenser.Errf("bad timeout value %s: %v", dispenser.Val(), err)
}
fcgiTransport.ReadTimeout = caddy.Duration(dur)
- dispenser.Delete()
- dispenser.Delete()
+ dispenser.DeleteN(2)
case "write_timeout":
if !dispenser.NextArg() {
@@ -307,15 +289,11 @@ func parsePHPFastCGI(h httpcaddyfile.Helper) ([]httpcaddyfile.ConfigValue, error
return nil, dispenser.Errf("bad timeout value %s: %v", dispenser.Val(), err)
}
fcgiTransport.WriteTimeout = caddy.Duration(dur)
- dispenser.Delete()
- dispenser.Delete()
+ dispenser.DeleteN(2)
case "capture_stderr":
args := dispenser.RemainingArgs()
- dispenser.Delete()
- for range args {
- dispenser.Delete()
- }
+ dispenser.DeleteN(len(args) + 1)
fcgiTransport.CaptureStderr = true
}
}
@@ -395,6 +373,7 @@ func parsePHPFastCGI(h httpcaddyfile.Helper) ([]httpcaddyfile.ConfigValue, error
// the rest of the config is specified by the user
// using the reverse_proxy directive syntax
+ dispenser.Next() // consume the directive name
err = rpHandler.UnmarshalCaddyfile(dispenser)
if err != nil {
return nil, err
diff --git a/modules/caddyhttp/reverseproxy/fastcgi/client.go b/modules/caddyhttp/reverseproxy/fastcgi/client.go
index ae36dd8..04513dd 100644
--- a/modules/caddyhttp/reverseproxy/fastcgi/client.go
+++ b/modules/caddyhttp/reverseproxy/fastcgi/client.go
@@ -251,7 +251,6 @@ func (c *client) Request(p map[string]string, req io.Reader) (resp *http.Respons
// Get issues a GET request to the fcgi responder.
func (c *client) Get(p map[string]string, body io.Reader, l int64) (resp *http.Response, err error) {
-
p["REQUEST_METHOD"] = "GET"
p["CONTENT_LENGTH"] = strconv.FormatInt(l, 10)
@@ -260,7 +259,6 @@ func (c *client) Get(p map[string]string, body io.Reader, l int64) (resp *http.R
// Head issues a HEAD request to the fcgi responder.
func (c *client) Head(p map[string]string) (resp *http.Response, err error) {
-
p["REQUEST_METHOD"] = "HEAD"
p["CONTENT_LENGTH"] = "0"
@@ -269,7 +267,6 @@ func (c *client) Head(p map[string]string) (resp *http.Response, err error) {
// Options issues an OPTIONS request to the fcgi responder.
func (c *client) Options(p map[string]string) (resp *http.Response, err error) {
-
p["REQUEST_METHOD"] = "OPTIONS"
p["CONTENT_LENGTH"] = "0"
diff --git a/modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go b/modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go
index ec194e7..31febdd 100644
--- a/modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go
+++ b/modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go
@@ -24,13 +24,13 @@ import (
"strings"
"time"
- "github.com/caddyserver/caddy/v2/modules/caddyhttp"
- "github.com/caddyserver/caddy/v2/modules/caddyhttp/reverseproxy"
- "github.com/caddyserver/caddy/v2/modules/caddytls"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
"github.com/caddyserver/caddy/v2"
+ "github.com/caddyserver/caddy/v2/modules/caddyhttp"
+ "github.com/caddyserver/caddy/v2/modules/caddyhttp/reverseproxy"
+ "github.com/caddyserver/caddy/v2/modules/caddytls"
)
var noopLogger = zap.NewNop()
@@ -171,6 +171,7 @@ func (t Transport) RoundTrip(r *http.Request) (*http.Response, error) {
rwc: conn,
reqID: 1,
logger: logger,
+ stderr: t.CaptureStderr,
}
// read/write timeouts
@@ -254,9 +255,7 @@ func (t Transport) buildEnv(r *http.Request) (envVars, error) {
// 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
- }
+ pathInfo, _ = repl.GetString("http.matchers.file.remainder")
}
// SCRIPT_FILENAME is the absolute path of SCRIPT_NAME
@@ -286,10 +285,7 @@ func (t Transport) buildEnv(r *http.Request) (envVars, error) {
reqHost = r.Host
}
- authUser := ""
- if val, ok := repl.Get("http.auth.user.id"); ok {
- authUser = val.(string)
- }
+ authUser, _ := repl.GetString("http.auth.user.id")
// Some variables are unused but cleared explicitly to prevent
// the parent environment from interfering.