mirror of
https://github.com/containers/podman.git
synced 2025-06-22 18:08:11 +08:00
Merge pull request #13636 from Luap99/machine-port-proxy
podman machine: fix port forwarding with proxy
This commit is contained in:
@ -11,6 +11,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/containers/common/libnetwork/types"
|
"github.com/containers/common/libnetwork/types"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
@ -36,7 +37,18 @@ func requestMachinePorts(expose bool, ports []types.PortMapping) error {
|
|||||||
url = url + "unexpose"
|
url = url + "unexpose"
|
||||||
}
|
}
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
client := &http.Client{}
|
client := &http.Client{
|
||||||
|
Transport: &http.Transport{
|
||||||
|
// make sure to not set a proxy here so explicitly ignore the proxy
|
||||||
|
// since we want to talk directly to gvproxy
|
||||||
|
// https://github.com/containers/podman/issues/13628
|
||||||
|
Proxy: nil,
|
||||||
|
MaxIdleConns: 50,
|
||||||
|
IdleConnTimeout: 30 * time.Second,
|
||||||
|
TLSHandshakeTimeout: 10 * time.Second,
|
||||||
|
ExpectContinueTimeout: 1 * time.Second,
|
||||||
|
},
|
||||||
|
}
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
for num, port := range ports {
|
for num, port := range ports {
|
||||||
protocols := strings.Split(port.Protocol, ",")
|
protocols := strings.Split(port.Protocol, ",")
|
||||||
@ -78,7 +90,6 @@ func requestMachinePorts(expose bool, ports []types.PortMapping) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func makeMachineRequest(ctx context.Context, client *http.Client, url string, buf io.Reader) error {
|
func makeMachineRequest(ctx context.Context, client *http.Client, url string, buf io.Reader) error {
|
||||||
//var buf io.ReadWriter
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, buf)
|
req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
Reference in New Issue
Block a user