mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
app/vmselect: follow-up after 8667307d73
This commit is contained in:
parent
8667307d73
commit
ce68e76d62
1 changed files with 14 additions and 10 deletions
|
@ -161,18 +161,19 @@ func RequestHandler(w http.ResponseWriter, r *http.Request) bool {
|
||||||
path = path[len("/graphite"):]
|
path = path[len("/graphite"):]
|
||||||
}
|
}
|
||||||
// vmui access.
|
// vmui access.
|
||||||
if strings.HasPrefix(path, "/vmui") {
|
if path == "/vmui" || path == "/graph" {
|
||||||
r.URL.Path = path
|
// VMUI access via incomplete url without `/` in the end. Redirect to complete url.
|
||||||
vmuiFileServer.ServeHTTP(w, r)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
if path == "/graph" {
|
|
||||||
// Redirect to /graph/, otherwise vmui redirects to /vmui/, which can be inaccessible in user env.
|
|
||||||
// Use relative redirect, since, since the hostname and path prefix may be incorrect if VictoriaMetrics
|
// Use relative redirect, since, since the hostname and path prefix may be incorrect if VictoriaMetrics
|
||||||
// is hidden behind vmauth or similar proxy.
|
// is hidden behind vmauth or similar proxy.
|
||||||
_ = r.ParseForm()
|
_ = r.ParseForm()
|
||||||
newURL := "graph/?" + r.Form.Encode()
|
path = strings.TrimPrefix(path, "/")
|
||||||
http.Redirect(w, r, newURL, http.StatusFound)
|
newURL := path + "/?" + r.Form.Encode()
|
||||||
|
http.Redirect(w, r, newURL, http.StatusMovedPermanently)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if strings.HasPrefix(path, "/vmui/") {
|
||||||
|
r.URL.Path = path
|
||||||
|
vmuiFileServer.ServeHTTP(w, r)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(path, "/graph/") {
|
if strings.HasPrefix(path, "/graph/") {
|
||||||
|
@ -213,7 +214,10 @@ func RequestHandler(w http.ResponseWriter, r *http.Request) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
if path == "/vmalert" {
|
if path == "/vmalert" {
|
||||||
http.Redirect(w, r, path+"/", http.StatusMovedPermanently)
|
// vmalert access via incomplete url without `/` in the end. Redirecto to complete url.
|
||||||
|
// Use relative redirect, since, since the hostname and path prefix may be incorrect if VictoriaMetrics
|
||||||
|
// is hidden behind vmauth or similar proxy.
|
||||||
|
http.Redirect(w, r, "vmalert/", http.StatusMovedPermanently)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if strings.HasPrefix(path, "/vmalert/") {
|
if strings.HasPrefix(path, "/vmalert/") {
|
||||||
|
|
Loading…
Reference in a new issue