Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 13, 21:45 UTC
fastcgi: Set SERVER_PORT to 80 or 443 depending on scheme (#4572)
ttys3 committed
Mar 3, 2022 at 02:24 UTC
de490c7cadc8c17759f747f5bb554967454c6529
1 file changed
+7
-2
modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go
+7
-2
@@ -296,10 +296,15 @@ func (t Transport) buildEnv(r *http.Request) (envVars, error) {
296
}
297
298
// compliance with the CGI specification requires that
299
- // SERVER_PORT should only exist if it's a valid numeric value.
300
- // Info: https://www.ietf.org/rfc/rfc3875 Page 18
299
+ // the SERVER_PORT variable MUST be set to the TCP/IP port number on which this request is received from the client
300
+ // even if the port is the default port for the scheme and could otherwise be omitted from a URI.
301
+ // https://tools.ietf.org/html/rfc3875#section-4.1.15
302
if reqPort != "" {
303
env["SERVER_PORT"] = reqPort
304
+ } else if requestScheme == "http" {
305
+ env["SERVER_PORT"] = "80"
306
+ } else if requestScheme == "https" {
307
+ env["SERVER_PORT"] = "443"
308
}
309
310
// Some web apps rely on knowing HTTPS or not