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
This commit is contained in:
Aliaksandr Valialkin 2021-12-02 13:51:49 +02:00
parent d1289383eb
commit c540235470
No known key found for this signature in database
GPG key ID: A72BEC6CD3D0DED1
2 changed files with 6 additions and 8 deletions

View file

@ -158,12 +158,12 @@ func requestHandler(w http.ResponseWriter, r *http.Request) bool {
fmt.Fprintf(w, "See docs at <a href='https://docs.victoriametrics.com/vmagent.html'>https://docs.victoriametrics.com/vmagent.html</a></br>")
fmt.Fprintf(w, "Useful endpoints:</br>")
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
}

View file

@ -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, "<a href=%q>%s</a> - %s<br/>", p, p, doc)
}
}