update reverseproxy from std libraries

This commit is contained in:
fatedier
2019-08-06 16:49:22 +08:00
parent ee0df07a3c
commit b53a2c1ed9
4 changed files with 289 additions and 147 deletions

View File

@@ -89,14 +89,18 @@ func NewHttpReverseProxy(option HttpReverseProxyOptions, vhostRouter *VhostRoute
return rp.CreateConnection(host, url, remote)
},
},
WebSocketDialContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
url := ctx.Value("url").(string)
host := getHostFromAddr(ctx.Value("host").(string))
remote := ctx.Value("remote").(string)
return rp.CreateConnection(host, url, remote)
},
//WebSocketDialContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
//url := ctx.Value("url").(string)
//host := getHostFromAddr(ctx.Value("host").(string))
//remote := ctx.Value("remote").(string)
//return rp.CreateConnection(host, url, remote)
//},
BufferPool: newWrapPool(),
ErrorLog: log.New(newWrapLogger(), "", 0),
ErrorHandler: func(rw http.ResponseWriter, req *http.Request, err error) {
rw.WriteHeader(http.StatusNotFound)
rw.Write(getNotFoundPageContent())
},
}
rp.proxy = proxy
return rp