From d88dd74deceb60433f6c7554328205d5d3e3bcc9 Mon Sep 17 00:00:00 2001 From: Wolfgang Johannes Kohnen Date: Sat, 30 Jul 2016 17:55:53 +0000 Subject: [PATCH] Re-enable HTTP/2 for Go 1.7. * Since Go 1.7 HTTP/2 support is enabled only if TLSConfig.NextProtos includes the string "h2". * see mholt/caddy#975 --- caddyhttp/httpserver/server.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/caddyhttp/httpserver/server.go b/caddyhttp/httpserver/server.go index 2a74e6e6..f42804d6 100644 --- a/caddyhttp/httpserver/server.go +++ b/caddyhttp/httpserver/server.go @@ -92,6 +92,10 @@ func NewServer(addr string, group []*SiteConfig) (*Server, error) { if err != nil { return nil, err } + // Since Go 1.7 HTTP/2 is enabled only if TLSConfig.NextProtos includes the string "h2". + if HTTP2 && s.Server.TLSConfig != nil && len(s.Server.TLSConfig.NextProtos) == 0 { + s.Server.TLSConfig.NextProtos = []string{"h2"} + } // Compile custom middleware for every site (enables virtual hosting) for _, site := range group {