Skip to content

Commit

Permalink
fix TLS when redirecting request
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Leung <[email protected]>
  • Loading branch information
rleungx committed Sep 9, 2019
1 parent b66ba44 commit 65f7767
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions server/api/redirector.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package api

import (
"crypto/tls"
"io/ioutil"
"net/http"
"net/url"
Expand Down Expand Up @@ -68,16 +69,28 @@ func (h *redirector) ServeHTTP(w http.ResponseWriter, r *http.Request, next http
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}

newCustomReverseProxies(urls).ServeHTTP(w, r)
tlsConfig, err := h.s.GetSecurityConfig().ToTLSConfig()
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
newCustomReverseProxies(urls, tlsConfig).ServeHTTP(w, r)
}

type customReverseProxies struct {
urls []url.URL
client *http.Client
}

func newCustomReverseProxies(urls []url.URL) *customReverseProxies {
func newCustomReverseProxies(urls []url.URL, cfg *tls.Config) *customReverseProxies {
if cfg != nil {
dialClient = &http.Client{
Transport: &http.Transport{
TLSClientConfig: cfg,
DisableKeepAlives: true,
},
}
}
p := &customReverseProxies{
client: dialClient,
}
Expand Down

0 comments on commit 65f7767

Please sign in to comment.