|
|
@ -99,3 +99,28 @@ func GetSiteInfoFromReq(master string, req *http.Request) (map[string]string, er |
|
|
|
} |
|
|
|
return siteInfo, nil |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 取访问主机名 |
|
|
|
*/ |
|
|
|
func GetHost(req *http.Request) string { |
|
|
|
|
|
|
|
var hostlist []string = req.Header.Values("X-Forwarded-Host") |
|
|
|
var host string |
|
|
|
if len(hostlist) > 1 { |
|
|
|
host = hostlist[len(hostlist)-1] //取最后一次转发的
|
|
|
|
} else if len(hostlist) == 1 { |
|
|
|
host = hostlist[0] |
|
|
|
} else { |
|
|
|
host = "" |
|
|
|
} |
|
|
|
if host != "" { |
|
|
|
hosts := strings.Split(host, ",") |
|
|
|
host = strings.Trim(hosts[len(hosts)-1], " ") |
|
|
|
} |
|
|
|
|
|
|
|
if host == "" { |
|
|
|
host = req.Host |
|
|
|
} |
|
|
|
return host |
|
|
|
} |