VictoriaMetrics icon indicating copy to clipboard operation
VictoriaMetrics copied to clipboard

vmauth fail to open vmui

Open v98765 opened this issue 3 years ago • 16 comments

Describe the bug vmauth generate wrong url to single-node VM. vmauth-host:8427/vmui/vmui/ and got 404 page not found

To Reproduce click on vmui url. http code:

See docs at <a href='https://docs.victoriametrics.com/'>https://docs.victoriametrics.com/</a></br>Useful endpoints:</br><a href="/vmui">/vmui</a> - Web UI<br/><a href="/targets">/targets</a> - discovered targets list<br/><a href="/api/v1/targets">/api/v1/targets</a> - advanced information about discovered targets in JSON format<br/><a href="/config">/config</a> - -promscrape.config contents<br/><a href="/metrics">/metrics</a> - available service metrics<br/><a href="/flags">/flags</a> - command-line flags<br/><a href="/api/v1/status/tsdb">/api/v1/status/tsdb</a> - tsdb status page<br/><a href="/api/v1/status/top_queries">/api/v1/status/top_queries</a> - top queries<br/><a href="/api/v1/status/active_queries">/api/v1/status/active_queries</a> - active queries<br/>

Expected behavior vmui works with vmauth

Version

vmauth-20211022-171212-tags-v1.68.0-0-gf64f62692
victoria-metrics-20211022-171155-tags-v1.68.0-0-gf64f62692

v98765 avatar Oct 26 '21 09:10 v98765

@v98765 , could you share the contents of the file pointed by -auth.config? Substitute sensitive information with star chars before sharing the file.

valyala avatar Oct 27 '21 17:10 valyala

label id = username

---
users:
- username: "1some"
  password: "demo"
  url_prefix: "http://localhost:8428?extra_label=id=1some"

v98765 avatar Oct 27 '21 18:10 v98765

this can help

---
users:
- username: "1some"
  password: "demo"
  url_map:
  - src_paths:
    - "/api/v1/query.*"
    - "/api/v1/label.+"
    url_prefix: "http://localhost:8428?extra_label=id=1some"

http://vmauth-host:8427/vmui/ error

remoteAddr: "**"; requestURI: /vmui/; cannot determine targetURL: missing route for "/vmui"

http://vmauth-host:8427/vmui redirect to http://vmauth-host:8427/vmui/vmui/?extra_label=id%3D1some and error is

remoteAddr: "**"; requestURI: /vmui/vmui/?extra_label=id%3D1some; cannot determine targetURL: missing route for "/vmui/vmui?extra_label=id%3D1some"

v98765 avatar Oct 28 '21 11:10 v98765

The config has no route for /vmui. Try extending the config to:

users:
- username: "1some"
  password: "demo"
  url_map:
  - src_paths:
    - "/api/v1/query.*"
    - "/api/v1/label.+"
    - "/vmui.*"
    url_prefix: "http://localhost:8428?extra_label=id=1some"

valyala avatar Oct 28 '21 12:10 valyala

redirect to /vmui/vmui/ and error 404 page not found

v98765 avatar Oct 28 '21 13:10 v98765

I'm seeing this with a trivial vmauth config.

users:
- {bearer_token: foobar, url_prefix: 'http://victoriametrics:8428'}

All requests to /vmui/ via vmauth return HTTP 301 with Location: vmui/ .

Sniffing the requests, it looks like vmauth strips the trailing slash from the path unconditionally but vmui insists on seeing it.

I tried backing up to v1.64.0 to see if this broke with 48f33d098b91a65fe406dc74f7b332afdf39a204 but that did not change the situation for me. But I suppose the path.Clean() call earlier (https://github.com/VictoriaMetrics/VictoriaMetrics/blob/master/app/vmauth/target_url.go#L41 ) already trims the slash.

Not sure if it's more easily fixed on the vmui side.

hy-ntyni avatar Jan 21 '22 09:01 hy-ntyni

I'm seeing this with a trivial vmauth config.

All requests to /vmui/ via vmauth return HTTP 301 with Location: vmui/ .

Sniffing the requests, it looks like vmauth strips the trailing slash from the path unconditionally but vmui insists on seeing it.

Hi, I think at least the 'need more info' tag could be removed from this issue. It should be trivial to reproduce.

Hope somebody finds the time to look at this :)

hy-ntyni avatar Feb 09 '22 15:02 hy-ntyni

any workaround ? deployed by operator the generated config like

- url_map:
  - url_prefix: http://vmselect-demo.monitoring-system.svc:8481/select/50
    src_paths:
    - /vmui
    - /vmui/vmui
    - /graph
    - /prometheus/graph
    - /prometheus/api/v1/label.*
    - /graphite.*
    - /prometheus/api/v1/query.*
    - /prometheus/api/v1/rules
    - /prometheus/api/v1/alerts
    - /prometheus/api/v1/metadata
    - /prometheus/api/v1/rules
    - /prometheus/api/v1/series.*
    - /prometheus/api/v1/status.*
    - /prometheus/api/v1/export.*
    - /prometheus/federate
    - /prometheus/api/v1/admin/tsdb/delete_series

but visit /vmui/ will redirect to vmui/ cause the final path is /vmui/vmui/

wenerme avatar Mar 02 '22 14:03 wenerme

Excuse me, has this problem been solved?

wking1986 avatar May 17 '22 07:05 wking1986

Hi,

Also affected by this issue: I'm using the VictoriaMetrics Kubernetes Operator and cannot access to the VMUI through VMAuth.

jonathanmarsaud avatar May 24 '22 13:05 jonathanmarsaud

same problem, anyone can help?

forever765 avatar Jun 12 '22 09:06 forever765

Same problem here with v1.72.

hamelg avatar Jun 17 '22 13:06 hamelg

Evaluating VictoriaMetrics - and seeing same problem. A bit worrying that this has not been ack'ed...

torbenaa avatar Jun 21 '22 11:06 torbenaa

Hi @f41gh7, could you help advise us on this?

nthienan avatar Jul 03 '22 15:07 nthienan

Same problem here with v1.79.0

adelbot avatar Jul 28 '22 08:07 adelbot

Same problem with v1.80.0

curl -sLI https://victoriametrics.fqdn:8247/vmui 
HTTP/1.1 301 Moved Permanently
Date: Mon, 08 Aug 2022 23:50:01 GMT
Location: vmui/?

HTTP/1.1 301 Moved Permanently
Date: Mon, 08 Aug 2022 23:50:01 GMT
Location: vmui/?

HTTP/1.1 404 Not Found
Content-Length: 19
Content-Type: text/plain; charset=utf-8
Date: Mon, 08 Aug 2022 23:50:01 GMT

tommysitehost avatar Aug 08 '22 23:08 tommysitehost

Can someone please provide an update on this? This is still an issue in v1.81.2.

zachmak avatar Sep 26 '22 20:09 zachmak

@dmitryk-dk , could you look into this issue?

valyala avatar Sep 30 '22 09:09 valyala

Yes, I will take a look!

dmitryk-dk avatar Sep 30 '22 09:09 dmitryk-dk

vmauth should properly open vmui after the commit a296994fed5f392d178a6a38edc1854041653135 . This commit will be included in the next release. In the mean time the bugfix can be tested by building vmauth from this commit according to these build instructions.

valyala avatar Oct 01 '22 13:10 valyala

FYI, the bugfix for this issue has been included in VictoriaMetrics v1.79.4 LTS release.

valyala avatar Oct 07 '22 00:10 valyala

vmauth should properly handle urls ending with / such as /vmui/ starting from v1.82.0. Closing the issue as fixed.

valyala avatar Oct 07 '22 02:10 valyala