From 5a41e8bc1acd040a51a1b30eeea9c29e91eecd8e Mon Sep 17 00:00:00 2001 From: Leonard Hecker Date: Fri, 10 Mar 2017 18:41:37 +0100 Subject: [PATCH] proxy: Fixed #1484, websockets with h2 disabled (#1488) * Fixed #1484 Fixed a nil pointer runtime error in newConnHijackerTransport, where the access to the TLSClientConfig did not check for nil values. * Minor improvement to UseInsecureTransport This prevents overwriting a possibly preexisting TLSClientConfig, even though only a single field should be changed. --- caddyhttp/proxy/reverseproxy.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/caddyhttp/proxy/reverseproxy.go b/caddyhttp/proxy/reverseproxy.go index 2627658a..336f9294 100644 --- a/caddyhttp/proxy/reverseproxy.go +++ b/caddyhttp/proxy/reverseproxy.go @@ -224,7 +224,10 @@ func (rp *ReverseProxy) UseInsecureTransport() { } rp.Transport = transport } else if transport, ok := rp.Transport.(*http.Transport); ok { - transport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true} + if transport.TLSClientConfig == nil { + transport.TLSClientConfig = &tls.Config{} + } + transport.TLSClientConfig.InsecureSkipVerify = true // No http2.ConfigureTransport() here. // For now this is only added in places where // an http.Transport is actually created. @@ -441,7 +444,7 @@ func newConnHijackerTransport(base http.RoundTripper) *connHijackerTransport { } if b, _ := base.(*http.Transport); b != nil { tlsClientConfig := b.TLSClientConfig - if tlsClientConfig.NextProtos != nil { + if tlsClientConfig != nil && tlsClientConfig.NextProtos != nil { tlsClientConfig = tlsClientConfig.Clone() tlsClientConfig.NextProtos = nil }