mirror of
https://github.com/yusing/godoxy.git
synced 2025-06-02 18:02:34 +02:00
fix(agent): docker handler
This commit is contained in:
parent
d8266f779f
commit
ff08c40403
1 changed files with 9 additions and 7 deletions
|
@ -6,7 +6,6 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httputil"
|
"net/http/httputil"
|
||||||
"net/url"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/yusing/go-proxy/agent/pkg/agent"
|
"github.com/yusing/go-proxy/agent/pkg/agent"
|
||||||
|
@ -32,12 +31,15 @@ func dialDockerSocket(ctx context.Context, _, _ string) (net.Conn, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func dockerSocketHandler() http.HandlerFunc {
|
func dockerSocketHandler() http.HandlerFunc {
|
||||||
rp := httputil.NewSingleHostReverseProxy(&url.URL{
|
rp := httputil.ReverseProxy{
|
||||||
Scheme: "http",
|
Director: func(r *http.Request) {
|
||||||
Host: "api.moby.localhost",
|
r.URL.Scheme = "http"
|
||||||
})
|
r.URL.Host = "api.moby.localhost"
|
||||||
rp.Transport = &http.Transport{
|
r.RequestURI = r.URL.String()
|
||||||
|
},
|
||||||
|
Transport: &http.Transport{
|
||||||
DialContext: dialDockerSocket,
|
DialContext: dialDockerSocket,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
return rp.ServeHTTP
|
return rp.ServeHTTP
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue