@@ -23,7 +23,8 @@ var badGatewayMessage = `<html>
2323// proxyTransport is a simple http.RoundTripper implementation which returns a
2424// 503 on any error making a request to the upstream (backend) service
2525type proxyTransport struct {
26- errMsg string
26+ transport * http.Transport
27+ errMsg string
2728}
2829
2930func (t * proxyTransport ) RoundTrip (request * http.Request ) (* http.Response , error ) {
@@ -34,7 +35,7 @@ func (t *proxyTransport) RoundTrip(request *http.Request) (*http.Response, error
3435 )
3536
3637 operation := func () error {
37- response , err = http . DefaultTransport .RoundTrip (request )
38+ response , err = t . transport .RoundTrip (request )
3839 // Handle Retry-After here, if you wish...
3940 // If err is nil, no retry will occur
4041 return err
@@ -59,7 +60,13 @@ func (t *proxyTransport) RoundTrip(request *http.Request) (*http.Response, error
5960}
6061
6162func createProxyTransport (targetURL url.URL , vhost string ) * proxyTransport {
62- return & proxyTransport {errMsg : fmt .Sprintf (badGatewayMessage , targetURL .String (), vhost )}
63+ fmt .Println ("creating new transport" )
64+ t := & proxyTransport {errMsg : fmt .Sprintf (badGatewayMessage , targetURL .String (), vhost )}
65+ t .transport = http .DefaultTransport .(* http.Transport ).Clone ()
66+ t .transport .MaxConnsPerHost = 0 // unlim
67+ t .transport .MaxIdleConns = 800
68+ t .transport .MaxIdleConnsPerHost = 8
69+ return t
6370}
6471
6572// CreateProxy with custom http.RoundTripper impl. Sets proper host headers
0 commit comments