Fix Forwarded HTTP header handling
"for" contains the port, if any. "port" doesn't exist.
This commit is contained in:
parent
9046fda283
commit
1b49fff763
@ -219,8 +219,8 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
|||||||
forwarded := parseForwarded(req.Header)
|
forwarded := parseForwarded(req.Header)
|
||||||
forwardedHost := req.Header.Get("X-Forwarded-For")
|
forwardedHost := req.Header.Get("X-Forwarded-For")
|
||||||
forwardedPort := req.Header.Get("X-Forwarded-Port")
|
forwardedPort := req.Header.Get("X-Forwarded-Port")
|
||||||
if forwarded["for"] != "" && forwarded["port"] != "" {
|
if forwarded["for"] != "" {
|
||||||
remoteAddr = net.JoinHostPort(forwarded["for"], forwarded["port"])
|
remoteAddr = forwarded["for"]
|
||||||
} else if forwardedHost != "" && forwardedPort != "" {
|
} else if forwardedHost != "" && forwardedPort != "" {
|
||||||
remoteAddr = net.JoinHostPort(forwardedHost, forwardedPort)
|
remoteAddr = net.JoinHostPort(forwardedHost, forwardedPort)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user