mirror of https://github.com/docker/docs.git
add tls to hijack as well
Signed-off-by: Victor Vieux <vieux@docker.com>
This commit is contained in:
parent
6552c7c884
commit
20018ff141
|
@ -220,7 +220,7 @@ func proxyContainerAndForceRefresh(c *context, w http.ResponseWriter, r *http.Re
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := proxy(container, w, r); err != nil {
|
if err := proxy(c.tlsConfig, container, w, r); err != nil {
|
||||||
httpError(w, err.Error(), http.StatusInternalServerError)
|
httpError(w, err.Error(), http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,7 +249,7 @@ func proxyHijack(c *context, w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := hijack(container, w, r); err != nil {
|
if err := hijack(c.tlsConfig, container, w, r); err != nil {
|
||||||
httpError(w, err.Error(), http.StatusInternalServerError)
|
httpError(w, err.Error(), http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
13
api/utils.go
13
api/utils.go
|
@ -65,7 +65,7 @@ func proxy(tlsConfig *tls.Config, container *cluster.Container, w http.ResponseW
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func hijack(container *cluster.Container, w http.ResponseWriter, r *http.Request) error {
|
func hijack(tlsConfig *tls.Config, container *cluster.Container, w http.ResponseWriter, r *http.Request) error {
|
||||||
addr := container.Node().Addr
|
addr := container.Node().Addr
|
||||||
if parts := strings.SplitN(container.Node().Addr, "://", 2); len(parts) == 2 {
|
if parts := strings.SplitN(container.Node().Addr, "://", 2); len(parts) == 2 {
|
||||||
addr = parts[1]
|
addr = parts[1]
|
||||||
|
@ -73,7 +73,16 @@ func hijack(container *cluster.Container, w http.ResponseWriter, r *http.Request
|
||||||
|
|
||||||
log.Debugf("[HIJACK PROXY] --> %s", addr)
|
log.Debugf("[HIJACK PROXY] --> %s", addr)
|
||||||
|
|
||||||
d, err := net.Dial("tcp", addr)
|
var (
|
||||||
|
d net.Conn
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
|
||||||
|
if tlsConfig != nil {
|
||||||
|
d, err = tls.Dial("tcp", addr, tlsConfig)
|
||||||
|
} else {
|
||||||
|
d, err = net.Dial("tcp", addr)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue