From e03a924236366cdea68c2265fc4f208bf32453b8 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Sat, 1 Oct 2022 16:52:27 +0300 Subject: [PATCH] app/vmauth: do not remove trailing slash from the proxied path This should fix the issue with opening VMUI at /vmui/ page. See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1752 --- app/vmauth/target_url.go | 11 ++++++++++- docs/CHANGELOG.md | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/vmauth/target_url.go b/app/vmauth/target_url.go index be5134b9cd..3df9a2e803 100644 --- a/app/vmauth/target_url.go +++ b/app/vmauth/target_url.go @@ -39,10 +39,19 @@ func createTargetURL(ui *UserInfo, uOrig *url.URL) (*url.URL, []Header, error) { u := *uOrig // Prevent from attacks with using `..` in r.URL.Path u.Path = path.Clean(u.Path) + if !strings.HasSuffix(u.Path, "/") && strings.HasSuffix(uOrig.Path, "/") { + // The path.Clean() removes traling slash. + // Return it back if needed. + // This should fix https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1752 + u.Path += "/" + } if !strings.HasPrefix(u.Path, "/") { u.Path = "/" + u.Path } - u.Path = strings.TrimSuffix(u.Path, "/") + if u.Path == "/" { + // See https://github.com/VictoriaMetrics/VictoriaMetrics/pull/1554 + u.Path = "" + } for _, e := range ui.URLMap { for _, sp := range e.SrcPaths { if sp.match(u.Path) { diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index a1f0cf9fb1..9ff5fe9326 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -48,6 +48,7 @@ See [these docs](https://docs.victoriametrics.com/Cluster-VictoriaMetrics.html#m * FEATURE: [vmagent](https://docs.victoriametrics.com/vmagent.html): accept data ingestion requests via paths starting from `/prometheus` prefix in the same way as [VictoriaMetrics does](https://docs.victoriametrics.com/#how-to-import-time-series-data). For example, `vmagent` now accepts Prometheus `remote_write` data via both `/api/v1/write` and `/prometheus/api/v1/write`. This simplifies switching between single-node VictoriaMetrics and `vmagent`. * FEATURE: [vmagent](https://docs.victoriametrics.com/vmagent.html): add `external_labels` from `global` section at `-promscrape.config` after the [relabeling](https://docs.victoriametrics.com/vmagent.html#relabeling) is applied to scraped metrics. This aligns with Prometheus behaviour. Previously the `external_labels` were added to scrape targets, so they could be modified during relabeling. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3137). +* BUGFIX: [vmauth](https://docs.victoriametrics.com/vmauth.html): properly handle request paths ending with `/` such as `/vmui/`. Previously `vmui` was dropping the traling `/`, which could prevent from using `vmui` via `vmauth`. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1752). * BUGFIX: [vmagent](https://docs.victoriametrics.com/vmagent.html): properly encode query params for aws signed requests, use `%20` instead of `+` as api requires. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3171). * BUGFIX: [vmagent](https://docs.victoriametrics.com/vmagent.html): properly parse relabel config when regex ending with escaped `$`. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3131). * BUGFIX: [MetricsQL](https://docs.victoriametrics.com/MetricsQL.html): properly calculate `rate_over_sum(m[d])` as `sum_over_time(m[d])/d`. Previously the `sum_over_time(m[d])` could be improperly divided by smaller than `d` time range. See [rate_over_sum() docs](https://docs.victoriametrics.com/MetricsQL.html#rate_over_sum) and [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3045).