From 4028d692f55fd604bf0d6ebe7fb559619fa4f8be Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Fri, 2 Apr 2021 22:54:06 +0300 Subject: [PATCH] app: do not process non-GET requests on at `/` handler --- app/vmagent/main.go | 3 +++ app/vmalert/web.go | 3 +++ app/vminsert/main.go | 3 +++ app/vmselect/main.go | 3 +++ app/vmstorage/main.go | 3 +++ 5 files changed, 15 insertions(+) diff --git a/app/vmagent/main.go b/app/vmagent/main.go index 7d7635a10..43552cf94 100644 --- a/app/vmagent/main.go +++ b/app/vmagent/main.go @@ -145,6 +145,9 @@ func main() { func requestHandler(w http.ResponseWriter, r *http.Request) bool { if r.URL.Path == "/" { + if r.Method != "GET" { + return false + } fmt.Fprintf(w, "vmagent - see docs at https://victoriametrics.github.io/vmagent.html") return true } diff --git a/app/vmalert/web.go b/app/vmalert/web.go index a095356d9..8fc71359e 100644 --- a/app/vmalert/web.go +++ b/app/vmalert/web.go @@ -29,6 +29,9 @@ var pathList = [][]string{ func (rh *requestHandler) handler(w http.ResponseWriter, r *http.Request) bool { switch r.URL.Path { case "/": + if r.Method != "GET" { + return false + } for _, path := range pathList { p, doc := path[0], path[1] fmt.Fprintf(w, "%q - %s
", p, p, doc) diff --git a/app/vminsert/main.go b/app/vminsert/main.go index d82c59798..f0d2244af 100644 --- a/app/vminsert/main.go +++ b/app/vminsert/main.go @@ -141,6 +141,9 @@ func main() { func requestHandler(w http.ResponseWriter, r *http.Request) bool { if r.URL.Path == "/" { + if r.Method != "GET" { + return false + } fmt.Fprintf(w, "vminsert - a component of VictoriaMetrics cluster. See docs at https://victoriametrics.github.io/Cluster-VictoriaMetrics.html") return true } diff --git a/app/vmselect/main.go b/app/vmselect/main.go index 95f668bd8..445ce0df0 100644 --- a/app/vmselect/main.go +++ b/app/vmselect/main.go @@ -128,6 +128,9 @@ var ( func requestHandler(w http.ResponseWriter, r *http.Request) bool { if r.URL.Path == "/" { + if r.Method != "GET" { + return false + } fmt.Fprintf(w, "vmselect - a component of VictoriaMetrics cluster. See docs at https://victoriametrics.github.io/Cluster-VictoriaMetrics.html") return true } diff --git a/app/vmstorage/main.go b/app/vmstorage/main.go index 34e301c01..4f7103f7e 100644 --- a/app/vmstorage/main.go +++ b/app/vmstorage/main.go @@ -120,6 +120,9 @@ func main() { func newRequestHandler(strg *storage.Storage) httpserver.RequestHandler { return func(w http.ResponseWriter, r *http.Request) bool { if r.URL.Path == "/" { + if r.Method != "GET" { + return false + } fmt.Fprintf(w, "vmstorage - a component of VictoriaMetrics cluster. See docs at https://victoriametrics.github.io/Cluster-VictoriaMetrics.html") return true }