From 464a61352c20ba91d11b7fd70270ac9a4dae7abf Mon Sep 17 00:00:00 2001 From: Simon Podlipsky Date: Tue, 30 Jan 2024 00:30:57 +0100 Subject: [PATCH] Docs: Add HAProxy rewrite information considering `serve_from_sub_path` setting (#80062) * docs: specify HAProxy rewrite considering `serve_from_sub_path` setting * Update docs/sources/tutorials/run-grafana-behind-a-proxy/index.md Co-authored-by: Joseph Perez <45749060+josmperez@users.noreply.github.com> * Update docs/sources/tutorials/run-grafana-behind-a-proxy/index.md Co-authored-by: Joseph Perez <45749060+josmperez@users.noreply.github.com> * Update docs/sources/tutorials/run-grafana-behind-a-proxy/index.md Co-authored-by: Joseph Perez <45749060+josmperez@users.noreply.github.com> * Update docs/sources/tutorials/run-grafana-behind-a-proxy/index.md * Update docs/sources/tutorials/run-grafana-behind-a-proxy/index.md Co-authored-by: Will Browne --------- Co-authored-by: Joseph Perez <45749060+josmperez@users.noreply.github.com> Co-authored-by: Will Browne --- .../run-grafana-behind-a-proxy/index.md | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/docs/sources/tutorials/run-grafana-behind-a-proxy/index.md b/docs/sources/tutorials/run-grafana-behind-a-proxy/index.md index 1c91e80579a..a9ca71db3c0 100644 --- a/docs/sources/tutorials/run-grafana-behind-a-proxy/index.md +++ b/docs/sources/tutorials/run-grafana-behind-a-proxy/index.md @@ -38,8 +38,8 @@ You can also serve Grafana behind a _sub path_, such as `http://example.com/graf To serve Grafana behind a sub path: -- Include the sub path at the end of the `root_url`. -- Set `serve_from_sub_path` to `true`. +1. Include the sub path at the end of the `root_url`. +1. Set `serve_from_sub_path` to `true`. Or, let proxy rewrite the path for you (refer to examples below). ```bash [server] @@ -149,11 +149,18 @@ frontend http-in use_backend grafana_backend if { path /grafana } or { path_beg /grafana/ } backend grafana_backend - # Requires haproxy >= 1.6 - http-request set-path %[path,regsub(^/grafana/?,/)] + server grafana localhost:3000 +``` - # Works for haproxy < 1.6 - # reqrep ^([^\ ]*\ /)grafana[/]?(.*) \1\2 +If your Grafana configuration doesn't set `server.serve_from_sub_path` to `true`, then you must add a rewrite rule to the `backend grafana_backend` block: + +```diff +backend grafana_backend ++ # Requires haproxy >= 1.6 ++ http-request set-path %[path,regsub(^/grafana/?,/)] + ++ # Works for haproxy < 1.6 ++ # reqrep ^([^\ ]*\ /)grafana[/]?(.*) \1\2 server grafana localhost:3000 ```