From bc838104506253137ad48af21d1abff586cfdfea Mon Sep 17 00:00:00 2001 From: kpacha Date: Tue, 1 Oct 2024 15:40:45 +0200 Subject: [PATCH] setup a timeout to avoid slowloris attacks --- exporter/prometheus/prometheus.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/exporter/prometheus/prometheus.go b/exporter/prometheus/prometheus.go index 2f5976a..36c5fae 100644 --- a/exporter/prometheus/prometheus.go +++ b/exporter/prometheus/prometheus.go @@ -42,8 +42,9 @@ func Exporter(ctx context.Context, cfg opencensus.Config) (*prometheus.Exporter, router := http.NewServeMux() router.Handle("/metrics", exporter) server := http.Server{ - Handler: router, - Addr: fmt.Sprintf(":%d", cfg.Exporters.Prometheus.Port), + Handler: router, + Addr: fmt.Sprintf(":%d", cfg.Exporters.Prometheus.Port), + ReadHeaderTimeout: 3 * time.Second, } go func() {