diff options
Diffstat (limited to 'modules/caddyhttp')
-rw-r--r-- | modules/caddyhttp/replacer.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/modules/caddyhttp/replacer.go b/modules/caddyhttp/replacer.go index f55bb0a..51fe67f 100644 --- a/modules/caddyhttp/replacer.go +++ b/modules/caddyhttp/replacer.go @@ -85,6 +85,9 @@ func addHTTPVarsToReplacer(repl *caddy.Replacer, req *http.Request, w http.Respo return host, true case "http.request.port": _, port, _ := net.SplitHostPort(req.Host) + if portNum, err := strconv.Atoi(port); err == nil { + return portNum, true + } return port, true case "http.request.hostport": return req.Host, true @@ -98,6 +101,9 @@ func addHTTPVarsToReplacer(repl *caddy.Replacer, req *http.Request, w http.Respo return host, true case "http.request.remote.port": _, port, _ := net.SplitHostPort(req.RemoteAddr) + if portNum, err := strconv.Atoi(port); err == nil { + return portNum, true + } return port, true // current URI, including any internal rewrites |