2
votes

Environment
OS: Redhat 7
ReverseProxy: Apache (only)
Deployed via: Docker

========================================================================

Issue:
Is it possible to make the change in Apache reverse proxy so that I can access the prometheus console by
"http://myserverurl/prometheus" -> "http://myserverurl/prometheus/graph"

instead of currently failing with
"http://myserverurl/prometheus" -> "http://myserverurl/graph" (FAIL)

After the reverse proxy, URL get redirected and /promethus disappeared.

In Grafana setting I was able to add option like

(#docker run -d -p 3000:3000 --name=grafana -e "GF_SERVER_ROOT_URL=http://0.0.0.0/grafana" grafana/grafana)

Which allows me to access Grafana console by
"http://myserverurl/grafana" -> "http://myserverurl/grafana/login" (SUCCESS)

========================================================================

Docker status:
docker run -d --name prometheus -p 9090:9090 prom/prometheus
Prometheus docker status

Tested configuration for proxypass: (Did not work)
ProxyPass /prometheus http://0.0.0.0:9090/prometheus
ProxyPassReverse /prometheus http://0.0.0.0:9090/prometheus

Action:
Tried to access the "http://myserverurl/prometheus"

Result Failed:
404 page not found

========================================================================

But it is working if I change the configuration as below:
ProxyPass / http://0.0.0.0:9090/
ProxyPassReverse / http://0.0.0.0:9090/

Access the url "http://myserverurl/" -> "http://myserverurl/graph"

Result success:
enter image description here ========================================================================
Also tried following combination - Does not work:
ProxyPass /promethus/ http://0.0.0.0:9090/
ProxyPassReverse /promethus/ http://0.0.0.0:9090/

1

1 Answers

2
votes

In order to have prometheus itself listen on /prometheus and not / you need to add a runtime parameters:

--web.route-prefix="prometheus"

--web.external-url="http://myserverurl/prometheus"

(at least in binary prometheus-2.7)

Prometheus invocation:

prometheus --web.listen-address="127.0.0.1:9090" --web.route-prefix="prometheus" --web.external-url="http://myserverurl/prometheus"

and also add symetric Apache rev-proxy:

ProxyPreserveHost On
ProxyRequests Off

ProxyPass        /prometheus http://127.0.0.1:9090/prometheus
ProxyPassReverse /prometheus http://127.0.0.1:9090/prometheus