summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorttys3 <41882455+ttys3@users.noreply.github.com>2022-03-03 02:24:16 +0800
committerGitHub <noreply@github.com>2022-03-02 11:24:16 -0700
commitde490c7cadc8c17759f747f5bb554967454c6529 (patch)
treedbafa385fe4a86e42a756fc48103dfeff3d0a8e1 /modules
parentbbad6931e30a2e74b3f53fff797d1115cc9dd491 (diff)
fastcgi: Set SERVER_PORT to 80 or 443 depending on scheme (#4572)
Diffstat (limited to 'modules')
-rw-r--r--modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go b/modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go
index 5404424..18d7e75 100644
--- a/modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go
+++ b/modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go
@@ -296,10 +296,15 @@ func (t Transport) buildEnv(r *http.Request) (envVars, error) {
}
// compliance with the CGI specification requires that
- // SERVER_PORT should only exist if it's a valid numeric value.
- // Info: https://www.ietf.org/rfc/rfc3875 Page 18
+ // the SERVER_PORT variable MUST be set to the TCP/IP port number on which this request is received from the client
+ // even if the port is the default port for the scheme and could otherwise be omitted from a URI.
+ // https://tools.ietf.org/html/rfc3875#section-4.1.15
if reqPort != "" {
env["SERVER_PORT"] = reqPort
+ } else if requestScheme == "http" {
+ env["SERVER_PORT"] = "80"
+ } else if requestScheme == "https" {
+ env["SERVER_PORT"] = "443"
}
// Some web apps rely on knowing HTTPS or not