From c54023547043bdc032e623d5456ee1ffaa2d758b Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Thu, 2 Dec 2021 13:51:49 +0200 Subject: [PATCH] app: use relative paths instead of absolute paths for the supported http handlers on the main page This allows hiding VictoriaMetrics components behind proxies, which serve pages at different path prefixes See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1858 --- app/vmagent/main.go | 12 ++++++------ lib/httpserver/httpserver.go | 2 -- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/app/vmagent/main.go b/app/vmagent/main.go index 7079c6b081..866dce3292 100644 --- a/app/vmagent/main.go +++ b/app/vmagent/main.go @@ -158,12 +158,12 @@ func requestHandler(w http.ResponseWriter, r *http.Request) bool { fmt.Fprintf(w, "See docs at https://docs.victoriametrics.com/vmagent.html
") fmt.Fprintf(w, "Useful endpoints:
") httpserver.WriteAPIHelp(w, [][2]string{ - {"/targets", "discovered targets list"}, - {"/api/v1/targets", "advanced information about discovered targets in JSON format"}, - {"/config", "-promscrape.config contents"}, - {"/metrics", "available service metrics"}, - {"/flags", "command-line flags"}, - {"/-/reload", "reload configuration"}, + {"targets", "discovered targets list"}, + {"api/v1/targets", "advanced information about discovered targets in JSON format"}, + {"config", "-promscrape.config contents"}, + {"metrics", "available service metrics"}, + {"flags", "command-line flags"}, + {"-/reload", "reload configuration"}, }) return true } diff --git a/lib/httpserver/httpserver.go b/lib/httpserver/httpserver.go index cf71892e70..1679576c4c 100644 --- a/lib/httpserver/httpserver.go +++ b/lib/httpserver/httpserver.go @@ -13,7 +13,6 @@ import ( "net/http" "net/http/pprof" "os" - "path" "runtime" "strconv" "strings" @@ -607,7 +606,6 @@ func GetPathPrefix() string { func WriteAPIHelp(w io.Writer, pathList [][2]string) { for _, p := range pathList { p, doc := p[0], p[1] - p = path.Join(*pathPrefix, p) fmt.Fprintf(w, "%s - %s
", p, p, doc) } }