mirror of
https://github.com/yusing/godoxy.git
synced 2025-06-01 01:22: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/http"
|
||||
"net/http/httputil"
|
||||
"net/url"
|
||||
"time"
|
||||
|
||||
"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 {
|
||||
rp := httputil.NewSingleHostReverseProxy(&url.URL{
|
||||
Scheme: "http",
|
||||
Host: "api.moby.localhost",
|
||||
})
|
||||
rp.Transport = &http.Transport{
|
||||
rp := httputil.ReverseProxy{
|
||||
Director: func(r *http.Request) {
|
||||
r.URL.Scheme = "http"
|
||||
r.URL.Host = "api.moby.localhost"
|
||||
r.RequestURI = r.URL.String()
|
||||
},
|
||||
Transport: &http.Transport{
|
||||
DialContext: dialDockerSocket,
|
||||
},
|
||||
}
|
||||
return rp.ServeHTTP
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue