mirror of
https://github.com/bingohuang/docker-labs.git
synced 2025-07-14 10:17:26 +08:00
Allow to access insecure https exposed services through proxy
This commit is contained in:
parent
a5d1e5c207
commit
c0bafc5f3b
@ -1,6 +1,7 @@
|
|||||||
package handlers
|
package handlers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/tls"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -23,6 +24,7 @@ func NewMultipleHostReverseProxy() *httputil.ReverseProxy {
|
|||||||
IdleConnTimeout: 100 * time.Millisecond,
|
IdleConnTimeout: 100 * time.Millisecond,
|
||||||
TLSHandshakeTimeout: 10 * time.Second,
|
TLSHandshakeTimeout: 10 * time.Second,
|
||||||
ExpectContinueTimeout: 1 * time.Second,
|
ExpectContinueTimeout: 1 * time.Second,
|
||||||
|
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
||||||
}
|
}
|
||||||
director := func(req *http.Request) {
|
director := func(req *http.Request) {
|
||||||
v := mux.Vars(req)
|
v := mux.Vars(req)
|
||||||
@ -42,8 +44,13 @@ func NewMultipleHostReverseProxy() *httputil.ReverseProxy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if port == "443" {
|
||||||
|
// Only proxy http for now
|
||||||
|
req.URL.Scheme = "https"
|
||||||
|
} else {
|
||||||
// Only proxy http for now
|
// Only proxy http for now
|
||||||
req.URL.Scheme = "http"
|
req.URL.Scheme = "http"
|
||||||
|
}
|
||||||
|
|
||||||
req.URL.Host = fmt.Sprintf("%s:%s", node, port)
|
req.URL.Host = fmt.Sprintf("%s:%s", node, port)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user