Unable to set up Apache reverse proxy with sub path, get "Page not found" error

  • What Grafana version and what operating system are you using?
    Grafana 12.0.0; Ubuntu 20.04.6

  • What are you trying to achieve?
    Make Grafana accessible on my server via https:/example.com/grafana
    (removed a ‘/’ from example URLs to comply with “only 2 links” rule)

  • How are you trying to achieve it?
    Installed Prometheus and Grafana, attempted to configure with the below settings.

  • What happened?
    If I go to https:/example.com/grafana I get redirected to https:/example.com/login, which is a 404 not found error page. If I go to https:/example.com/grafana/login, I get a “Page not found” page in the Grafana interface (screenshot).

  • What did you expect to happen?
    To get the Grafana login page.

  • Can you copy/paste the configuration(s) that you are having problems with?
    grafana.ini:

[server]
;protocol = http
;http_port = 3000
;domain = example.com
;root_url = %(protocol)s://%s(domain)s:%(http_port)s/grafana
;serve_from_sub_path = true
;cert_file = /etc/grafana/grafana.crt
;cert_key = /etc/grafana/grafana.key

apache config:

<VirtualHost *:443>
  ServerName example.com

  ProxyPreserveHost on
  ProxyPass /grafana http://127.0.0.1:3000
  ProxyPassReverse /grafana http://127.0.0.1:3000
</VirtualHost>
  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
    The logs didn’t appear to have any errors, I just got that “page not found” error in my browser.

  • Did you follow any online instructions? If so, what is the URL?
    I tried following the “Run Grafana behind a reverse proxy” tutorial, which didn’t help.
    I also tried following the “Set up Grafana HTTPS for secure web traffic” tutorial, which didn’t help either.
    I would include the URLs for the above tutorials, but the “only 2 links” rule doesn’t allow me.
    I found https://stackoverflow.com/a/73124691 and with some adjustments I was able to at least reach the “Page not found” page.