diff options
author | feistel <6742251-feistel@users.noreply.gitlab.com> | 2021-05-20 22:27:45 +0300 |
---|---|---|
committer | feistel <6742251-feistel@users.noreply.gitlab.com> | 2021-06-22 22:17:07 +0300 |
commit | 8b2b037fbbc178178fe5431cb08566c9ac1e85d0 (patch) | |
tree | ffcb5c6f0ddcd7a3e7381482b713a5b8c08e4eee /server.go | |
parent | afeb8a4cdc17289b83f5e7d77aebb9a0e62e2f58 (diff) |
Fix http2 flag and drop usage of x/net/http2
gitlab pages is using (*Server).Serve.
Go enable HTTP/2 by default if the user hasn't otherwise
configured their TLSNextProto map.
However this is only done if there's no TLSConfig (srv.TLSConfig
is null) or if the user specified a TLSConfig on their http.Server
and explicitly requested the 'h2' protocol.
Diffstat (limited to 'server.go')
-rw-r--r-- | server.go | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -10,7 +10,6 @@ import ( "github.com/gorilla/context" proxyproto "github.com/pires/go-proxyproto" - "golang.org/x/net/http2" "gitlab.com/gitlab-org/gitlab-pages/internal/netutil" ) @@ -49,11 +48,12 @@ func (a *theApp) listenAndServe(config listenerConfig) error { // create server server := &http.Server{Handler: context.ClearHandler(config.handler), TLSConfig: config.tlsConfig} - if a.config.General.HTTP2 { - err := http2.ConfigureServer(server, &http2.Server{}) - if err != nil { - return err - } + if a.config.General.HTTP2 && server.TLSConfig != nil { + server.TLSConfig.NextProtos = append(server.TLSConfig.NextProtos, "h2") + } + + if !a.config.General.HTTP2 { + server.TLSNextProto = make(map[string]func(*http.Server, *tls.Conn, http.Handler)) } l, err := net.FileListener(os.NewFile(config.fd, "[socket]")) |