mirror of
https://github.com/pomerium/pomerium.git
synced 2025-06-08 05:42:47 +02:00
xds: force ipv4 for localhost to workaround ipv6 issue in docker compose (#819)
This commit is contained in:
parent
12e373249b
commit
fca17d365a
2 changed files with 38 additions and 0 deletions
|
@ -271,4 +271,34 @@ func Test_buildCluster(t *testing.T) {
|
||||||
}
|
}
|
||||||
`, cluster)
|
`, cluster)
|
||||||
})
|
})
|
||||||
|
t.Run("localhost", func(t *testing.T) {
|
||||||
|
cluster := buildCluster("example", mustParseURL("http://localhost"), nil, true)
|
||||||
|
testutil.AssertProtoJSONEqual(t, `
|
||||||
|
{
|
||||||
|
"name": "example",
|
||||||
|
"type": "STATIC",
|
||||||
|
"connectTimeout": "10s",
|
||||||
|
"respectDnsTtl": true,
|
||||||
|
"http2ProtocolOptions": {
|
||||||
|
"allowConnect": true
|
||||||
|
},
|
||||||
|
"loadAssignment": {
|
||||||
|
"clusterName": "example",
|
||||||
|
"endpoints": [{
|
||||||
|
"lbEndpoints": [{
|
||||||
|
"endpoint": {
|
||||||
|
"address": {
|
||||||
|
"socketAddress": {
|
||||||
|
"address": "127.0.0.1",
|
||||||
|
"ipv4Compat": true,
|
||||||
|
"portValue": 80
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`, cluster)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"net"
|
"net"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
envoy_config_cluster_v3 "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3"
|
envoy_config_cluster_v3 "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3"
|
||||||
|
@ -185,6 +186,13 @@ func buildCluster(
|
||||||
defaultPort = 443
|
defaultPort = 443
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if endpoint.Hostname() == "localhost" {
|
||||||
|
u := new(url.URL)
|
||||||
|
*u = *endpoint
|
||||||
|
u.Host = strings.Replace(endpoint.Host, "localhost", "127.0.0.1", -1)
|
||||||
|
endpoint = u
|
||||||
|
}
|
||||||
|
|
||||||
cluster := &envoy_config_cluster_v3.Cluster{
|
cluster := &envoy_config_cluster_v3.Cluster{
|
||||||
Name: name,
|
Name: name,
|
||||||
ConnectTimeout: ptypes.DurationProto(time.Second * 10),
|
ConnectTimeout: ptypes.DurationProto(time.Second * 10),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue