From 16b433791b619f4144110e4429d98684bf5e98eb Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Sat, 25 May 2024 18:10:30 +0200 Subject: feat: support cleartext HTTP/2 (i.e. from a reverse proxy) --- internal/server/server.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'internal/server/server.go') diff --git a/internal/server/server.go b/internal/server/server.go index 262e9a7..38200bb 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -11,6 +11,8 @@ import ( "time" "github.com/pkg/errors" + "golang.org/x/net/http2" + "golang.org/x/net/http2/h2c" ) type Server struct { @@ -28,7 +30,12 @@ func New(conf *config.Config, index *index.ReadIndex, liveReload bool) (*Server, return &Server{ cfg: conf, server: &http.Server{ - Handler: mux, + Handler: http.MaxBytesHandler( + h2c.NewHandler(mux, &http2.Server{ + IdleTimeout: 5 * time.Minute, + }), + 1024*1024, + ), ReadHeaderTimeout: 20 * time.Second, }, }, nil -- cgit 1.4.1