summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Dittberner <jandd@cacert.org>2020-04-26 13:18:58 +0200
committerJan Dittberner <jandd@cacert.org>2020-04-26 13:18:58 +0200
commit594df29dc132c1573dddda3883eb4a31cdd99756 (patch)
treea14d0beafdee7fd7612516474ff9258eb5cf3c64
parentbf67dfbc1010837e76d0a74f25dcb1a3a8ccf09b (diff)
downloadcacert-boardvoting-594df29dc132c1573dddda3883eb4a31cdd99756.tar.gz
cacert-boardvoting-594df29dc132c1573dddda3883eb4a31cdd99756.tar.xz
cacert-boardvoting-594df29dc132c1573dddda3883eb4a31cdd99756.zip
Explicitly define timeouts for http and httpsHEADmaster
-rw-r--r--boardvoting.go18
1 files changed, 15 insertions, 3 deletions
diff --git a/boardvoting.go b/boardvoting.go
index 1bd0cf0..dca1985 100644
--- a/boardvoting.go
+++ b/boardvoting.go
@@ -846,8 +846,12 @@ func main() {
defer stopAll()
server := &http.Server{
- Addr: config.HttpsAddress,
- TLSConfig: tlsConfig,
+ Addr: config.HttpsAddress,
+ TLSConfig: tlsConfig,
+ IdleTimeout: time.Second * 120,
+ ReadHeaderTimeout: time.Second * 10,
+ ReadTimeout: time.Second * 20,
+ WriteTimeout: time.Second * 60,
}
server.Handler = csrf.Protect(csrfKey)(http.DefaultServeMux)
@@ -856,7 +860,15 @@ func main() {
errs := make(chan error, 1)
go func() {
- if err := http.ListenAndServe(config.HttpsAddress, http.RedirectHandler(config.BaseURL, http.StatusMovedPermanently)); err != nil {
+ httpRedirector := &http.Server{
+ Addr: config.HttpAddress,
+ Handler: http.RedirectHandler(config.BaseURL, http.StatusMovedPermanently),
+ IdleTimeout: time.Second * 5,
+ ReadHeaderTimeout: time.Second * 10,
+ ReadTimeout: time.Second * 10,
+ WriteTimeout: time.Second * 60,
+ }
+ if err := httpRedirector.ListenAndServe(); err != nil {
errs <- err
}
close(errs)