Skip to content

Commit

Permalink
more comments about fastcgi buffering
Browse files Browse the repository at this point in the history
  • Loading branch information
WeidiDeng committed Jan 2, 2025
1 parent 7b193d5 commit 3ba88fe
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion modules/caddyhttp/reverseproxy/reverseproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,15 @@ func (h *Handler) Provision(ctx caddy.Context) error {
}
h.Transport = mod.(http.RoundTripper)
// enable request buffering for fastcgi if not configured
// TODO: better default buffering for fastcgi requests without content length
// This is because most fastcgi servers are php-fpm that require the content length to be set to read the body, golang
// std has fastcgi implementation that doesn't need this value to process the body, but we can safely assume that's
// not used.
// http3 requests have a negative content length for GET and HEAD requests, if that header is not sent.
// see: https://github.com/caddyserver/caddy/issues/6678#issuecomment-2472224182
// Though it appears even if CONTENT_LENGTH is invalid, php-fpm can handle just fine if the body is empty (no Stdin records sent).
// php-fpm will hang if there is any data in the body though, https://github.com/caddyserver/caddy/issues/5420#issuecomment-2415943516

// TODO: better default buffering for fastcgi requests without content length, in theory a value of 1 should be enough, make it bigger anyway
if module, ok := h.Transport.(caddy.Module); ok && module.CaddyModule().ID.Name() == "fastcgi" && h.RequestBuffers == 0 {
h.RequestBuffers = 4096
}
Expand Down

0 comments on commit 3ba88fe

Please sign in to comment.