1
0
mirror of https://github.com/bingohuang/docker-labs.git synced 2025-10-05 18:03:21 +08:00

Add TLS certificates for machine drivers (#73)

This commit is contained in:
Marcos Nils
2016-12-27 18:53:50 +02:00
committed by GitHub
parent 93740dc9f5
commit dea778440e
8 changed files with 168 additions and 27 deletions

View File

@@ -37,3 +37,27 @@ func NewMultipleHostReverseProxy() *httputil.ReverseProxy {
return &httputil.ReverseProxy{Director: director}
}
func NewSSLDaemonHandler() *httputil.ReverseProxy {
director := func(req *http.Request) {
v := mux.Vars(req)
node := v["node"]
if strings.HasPrefix(node, "ip") {
// Node is actually an ip, need to convert underscores by dots.
ip := strings.Replace(strings.TrimPrefix(node, "ip"), "_", ".", -1)
if net.ParseIP(ip) == nil {
// Not a valid IP, so treat this is a hostname.
} else {
node = ip
}
}
// Only proxy http for now
req.URL.Scheme = "http"
req.URL.Host = fmt.Sprintf("%s:%s", node, "2375")
}
return &httputil.ReverseProxy{Director: director}
}