mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-28 08:27:26 +02:00
envoy: fix sni/hostname mismatched routing for http2 connection coalescing (#703)
This commit is contained in:
parent
65bb1501fd
commit
1bee3b0df9
5 changed files with 79 additions and 10 deletions
|
@ -24,15 +24,20 @@ func New(workingDir string) *Cluster {
|
|||
}
|
||||
}
|
||||
|
||||
// NewHTTPClient creates a new *http.Client, with a cookie jar, and a LocalRoundTripper
|
||||
// which routes traffic to the nginx ingress controller.
|
||||
// NewHTTPClient calls NewHTTPClientWithTransport with the default cluster transport.
|
||||
func (cluster *Cluster) NewHTTPClient() *http.Client {
|
||||
return cluster.NewHTTPClientWithTransport(cluster.Transport)
|
||||
}
|
||||
|
||||
// NewHTTPClientWithTransport creates a new *http.Client, with a cookie jar, and a LocalRoundTripper
|
||||
// which routes traffic to the nginx ingress controller.
|
||||
func (cluster *Cluster) NewHTTPClientWithTransport(transport http.RoundTripper) *http.Client {
|
||||
jar, err := cookiejar.New(&cookiejar.Options{PublicSuffixList: publicsuffix.List})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return &http.Client{
|
||||
Transport: &loggingRoundTripper{cluster.Transport},
|
||||
Transport: &loggingRoundTripper{transport},
|
||||
CheckRedirect: func(req *http.Request, via []*http.Request) error {
|
||||
return http.ErrUseLastResponse
|
||||
},
|
||||
|
|
|
@ -51,7 +51,7 @@ func (cluster *Cluster) Setup(ctx context.Context) error {
|
|||
return err
|
||||
}
|
||||
|
||||
hostport, err := cluster.getNodeHTTPSAddr(ctx)
|
||||
hostport, err := cluster.GetNodePortAddr(ctx, "ingress-nginx", "ingress-nginx-nodeport")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -68,11 +68,12 @@ func (cluster *Cluster) Setup(ctx context.Context) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (cluster *Cluster) getNodeHTTPSAddr(ctx context.Context) (hostport string, err error) {
|
||||
// GetNodePortAddr returns the node:port address for a NodePort kubernetes service.
|
||||
func (cluster *Cluster) GetNodePortAddr(ctx context.Context, namespace, svcName string) (hostport string, err error) {
|
||||
var buf bytes.Buffer
|
||||
|
||||
args := []string{"get", "service", "--namespace", "ingress-nginx", "--output", "json",
|
||||
"ingress-nginx-nodeport"}
|
||||
args := []string{"get", "service", "--namespace", namespace, "--output", "json",
|
||||
svcName}
|
||||
err = run(ctx, "kubectl", withArgs(args...), withStdout(&buf))
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("error getting service details with kubectl: %w", err)
|
||||
|
@ -94,7 +95,7 @@ func (cluster *Cluster) getNodeHTTPSAddr(ctx context.Context) (hostport string,
|
|||
|
||||
buf.Reset()
|
||||
|
||||
args = []string{"get", "pods", "--namespace", "ingress-nginx", "--output", "json"}
|
||||
args = []string{"get", "pods", "--namespace", namespace, "--output", "json"}
|
||||
var sel []string
|
||||
for k, v := range svcResult.Spec.Selector {
|
||||
sel = append(sel, k+"="+v)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue