@@ -59,7 +59,7 @@ func NewHTTPReverseProxy(option HTTPReverseProxyOptions, vhostRouter *Routers) *
59
59
Director : func (req * http.Request ) {
60
60
req .URL .Scheme = "http"
61
61
url := req .Context ().Value (RouteInfoURL ).(string )
62
- oldHost := util .GetHostFromAddr (req .Context ().Value (RouteInfoHost ).(string ))
62
+ oldHost , _ := util .CanonicalHost (req .Context ().Value (RouteInfoHost ).(string ))
63
63
rc := rp .GetRouteConfig (oldHost , url )
64
64
if rc != nil {
65
65
if rc .RewriteHost != "" {
@@ -81,7 +81,7 @@ func NewHTTPReverseProxy(option HTTPReverseProxyOptions, vhostRouter *Routers) *
81
81
IdleConnTimeout : 60 * time .Second ,
82
82
DialContext : func (ctx context.Context , network , addr string ) (net.Conn , error ) {
83
83
url := ctx .Value (RouteInfoURL ).(string )
84
- host := util .GetHostFromAddr (ctx .Value (RouteInfoHost ).(string ))
84
+ host , _ := util .CanonicalHost (ctx .Value (RouteInfoHost ).(string ))
85
85
remote := ctx .Value (RouteInfoRemote ).(string )
86
86
return rp .CreateConnection (host , url , remote )
87
87
},
@@ -191,7 +191,7 @@ func (rp *HTTPReverseProxy) getVhost(domain string, location string) (vr *Router
191
191
}
192
192
193
193
func (rp * HTTPReverseProxy ) ServeHTTP (rw http.ResponseWriter , req * http.Request ) {
194
- domain := util .GetHostFromAddr (req .Host )
194
+ domain , _ := util .CanonicalHost (req .Host )
195
195
location := req .URL .Path
196
196
user , passwd , _ := req .BasicAuth ()
197
197
if ! rp .CheckAuth (domain , location , user , passwd ) {
0 commit comments