From 59aad26e296b6dad1d8b67684cb040f366ff4b3b Mon Sep 17 00:00:00 2001 From: Will Norris Date: Tue, 8 Nov 2022 17:04:39 -0800 Subject: [PATCH] cmd/imageproxy: add proper server timeouts --- cmd/imageproxy/main.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/cmd/imageproxy/main.go b/cmd/imageproxy/main.go index 68bf2ae..546b6ff 100644 --- a/cmd/imageproxy/main.go +++ b/cmd/imageproxy/main.go @@ -90,15 +90,20 @@ func main() { p.Verbose = *verbose p.UserAgent = *userAgent - server := &http.Server{ - Addr: *addr, - Handler: p, - } - r := mux.NewRouter().SkipClean(true).UseEncodedPath() r.PathPrefix("/").Handler(p) + + server := &http.Server{ + Addr: *addr, + Handler: r, + + ReadTimeout: 10 * time.Second, + WriteTimeout: 30 * time.Second, + IdleTimeout: 120 * time.Second, + } + fmt.Printf("imageproxy listening on %s\n", server.Addr) - log.Fatal(http.ListenAndServe(*addr, r)) + log.Fatal(server.ListenAndServe()) } type signatureKeyList [][]byte