custom proxy director

pull/94/head
Baokun Lee 2019-08-04 13:31:18 +08:00 committed by kun
parent 769cffd5df
commit 49360a363a
1 changed files with 8 additions and 1 deletions

View File

@ -32,7 +32,14 @@ func NewRouter(srv *Server, ops *RouterOps) *Router {
}
if ops != nil {
if remote, err := url.Parse(ops.Proxy); err == nil {
rt.proxy = httputil.NewSingleHostReverseProxy(remote)
proxy := httputil.NewSingleHostReverseProxy(remote)
director := proxy.Director
proxy.Director = func(r *http.Request) {
director(r)
r.Host = remote.Host
}
rt.proxy = proxy
rt.proxy.Transport = &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}