]> source.dussan.org Git - gitea.git/commitdiff
Support HTTP/2 in Let's Encrypt (#16371)
authorStanley Hu <stanthetiger@yahoo.com>
Tue, 13 Jul 2021 17:17:46 +0000 (01:17 +0800)
committerGitHub <noreply@github.com>
Tue, 13 Jul 2021 17:17:46 +0000 (18:17 +0100)
Modify the tlsConfig.NextProtos for Let's Encrypt and built-in HTTPS server in order to support HTTP/2.

Co-authored-by: 6543 <6543@obermui.de>
cmd/web_letsencrypt.go
modules/graceful/server.go

index d50d803e1da731dc0b8f060960c02f9c5537c2cf..a68399979035eaf579cd39d0c48e6c1ce3af2c36 100644 (file)
@@ -54,6 +54,7 @@ func runLetsEncrypt(listenAddr, domain, directory, email string, m http.Handler)
        }
 
        tlsConfig := magic.TLSConfig()
+       tlsConfig.NextProtos = append(tlsConfig.NextProtos, "h2")
 
        if enableHTTPChallenge {
                go func() {
index 704aa8a2b71f118e3402f99b3744abeffd1509ef..6b7d4a1a970c16ad8e20975ff139d8a8ecc1f4b9 100644 (file)
@@ -106,7 +106,7 @@ func (srv *Server) ListenAndServe(serve ServeFunction) error {
 func (srv *Server) ListenAndServeTLS(certFile, keyFile string, serve ServeFunction) error {
        config := &tls.Config{}
        if config.NextProtos == nil {
-               config.NextProtos = []string{"http/1.1"}
+               config.NextProtos = []string{"h2", "http/1.1"}
        }
 
        config.Certificates = make([]tls.Certificate, 1)