mirror of
https://github.com/yusing/godoxy.git
synced 2025-05-19 20:32:35 +02:00
fix: docker socket handler
This commit is contained in:
parent
2c0b68c8c2
commit
0208e6286f
2 changed files with 10 additions and 8 deletions
|
@ -47,4 +47,5 @@ COPY --from=builder /app/run /app/run
|
|||
|
||||
WORKDIR /app
|
||||
|
||||
ENV LISTEN_ADDR=0.0.0.0:2375
|
||||
CMD ["/app/run"]
|
|
@ -9,8 +9,6 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
|
||||
"net/url"
|
||||
)
|
||||
|
||||
var dialer = &net.Dialer{KeepAlive: 1 * time.Second}
|
||||
|
@ -22,12 +20,15 @@ func dialDockerSocket(ctx context.Context, _, _ string) (net.Conn, error) {
|
|||
var DockerSocketHandler = dockerSocketHandler
|
||||
|
||||
func dockerSocketHandler() http.HandlerFunc {
|
||||
rp := httputil.NewSingleHostReverseProxy(&url.URL{
|
||||
Scheme: "http",
|
||||
Host: "api.moby.localhost",
|
||||
})
|
||||
rp.Transport = &http.Transport{
|
||||
DialContext: dialDockerSocket,
|
||||
rp := &httputil.ReverseProxy{
|
||||
Director: func(req *http.Request) {
|
||||
req.URL.Scheme = "http"
|
||||
req.URL.Host = "api.moby.localhost"
|
||||
req.RequestURI = req.URL.String()
|
||||
},
|
||||
Transport: &http.Transport{
|
||||
DialContext: dialDockerSocket,
|
||||
},
|
||||
}
|
||||
|
||||
return rp.ServeHTTP
|
||||
|
|
Loading…
Add table
Reference in a new issue