Skip to content

Commit

Permalink
Use transport proxy instead of a special custom header
Browse files Browse the repository at this point in the history
  • Loading branch information
xetorthio committed Aug 4, 2017
1 parent defe855 commit f810c0c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions docker/local_cached_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"log"
"net"
"net/http"
"net/url"
"sync"
"time"

Expand Down Expand Up @@ -87,18 +88,21 @@ func (f *localCachedFactory) GetForInstance(sessionId, instanceName string) (Doc
tlsConfig.Certificates = []tls.Certificate{tlsCert}
}

proxyUrl, _ := url.Parse("http://l2:443")
transport := &http.Transport{
DialContext: (&net.Dialer{
Timeout: 1 * time.Second,
KeepAlive: 30 * time.Second,
}).DialContext}
}).DialContext,
Proxy: http.ProxyURL(proxyUrl),
}
if tlsConfig != nil {
transport.TLSClientConfig = tlsConfig
}
cli := &http.Client{
Transport: transport,
}
dc, err := client.NewClient("http://l2:443", api.DefaultVersion, cli, map[string]string{"X-Forwarded-Host": router.EncodeHost(instance.SessionId, instance.IP, router.HostOpts{EncodedPort: 2375})})
dc, err := client.NewClient(fmt.Sprintf("http://%s", router.EncodeHost(instance.SessionId, instance.IP, router.HostOpts{EncodedPort: 2375})), api.DefaultVersion, cli, nil)
if err != nil {
return nil, fmt.Errorf("Could not connect to DinD docker daemon", err)
}
Expand Down

0 comments on commit f810c0c

Please sign in to comment.