Browse Source

Merge pull request #5034 from ZhuPeng/proxy-http2

Enable http2 support between proxy and member
Xiang Li 9 years ago
parent
commit
f15b5aa4e6
1 changed files with 10 additions and 0 deletions
  1. 10 0
      proxy/httpproxy/proxy.go

+ 10 - 0
proxy/httpproxy/proxy.go

@@ -19,6 +19,8 @@ import (
 	"net/http"
 	"strings"
 	"time"
+
+	"golang.org/x/net/http2"
 )
 
 const (
@@ -42,6 +44,14 @@ type GetProxyURLs func() []string
 // which will proxy requests to an etcd cluster.
 // The handler will periodically update its view of the cluster.
 func NewHandler(t *http.Transport, urlsFunc GetProxyURLs, failureWait time.Duration, refreshInterval time.Duration) http.Handler {
+	if t.TLSClientConfig != nil {
+		// Enable http2, see Issue 5033.
+		err := http2.ConfigureTransport(t)
+		if err != nil {
+			plog.Infof("Error enabling Transport HTTP/2 support: %v", err)
+		}
+	}
+
 	p := &reverseProxy{
 		director:  newDirector(urlsFunc, failureWait, refreshInterval),
 		transport: t,