From 6352c9054ab7a72460f6b75c0be797eaff9d0a67 Mon Sep 17 00:00:00 2001 From: Leonard Hecker Date: Mon, 26 Dec 2016 20:40:44 +0100 Subject: [PATCH] Fixed proxy not respecting the -http2 flag --- caddyhttp/proxy/reverseproxy.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/caddyhttp/proxy/reverseproxy.go b/caddyhttp/proxy/reverseproxy.go index cfb466c7..050e7fb9 100644 --- a/caddyhttp/proxy/reverseproxy.go +++ b/caddyhttp/proxy/reverseproxy.go @@ -148,7 +148,9 @@ func NewSingleHostReverseProxy(target *url.URL, without string, keepalive int) * } else { transport.MaxIdleConnsPerHost = keepalive } - http2.ConfigureTransport(transport) + if httpserver.HTTP2 { + http2.ConfigureTransport(transport) + } rp.Transport = transport } return rp @@ -168,10 +170,15 @@ func (rp *ReverseProxy) UseInsecureTransport() { TLSHandshakeTimeout: 10 * time.Second, TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, } - http2.ConfigureTransport(transport) + if httpserver.HTTP2 { + http2.ConfigureTransport(transport) + } rp.Transport = transport } else if transport, ok := rp.Transport.(*http.Transport); ok { transport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true} + // No http2.ConfigureTransport() here. + // For now this is only added in places where + // an http.Transport is actually created. } }