【问题标题】:Prometheus (via Docker) - Reverse proxy (via Apache) redirect issuePrometheus (via Docker) - 反向代理 (via Apache) 重定向问题
【发布时间】:2018-09-23 11:02:49
【问题描述】:

环境
操作系统:红帽 7
ReverseProxy:Apache(仅限)
部署方式:Docker

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

问题:
是否可以在 Apache 反向代理中进行更改,以便我可以通过
访问 prometheus 控制台 "http://myserverurl/prometheus" -> "http://myserverurl/prometheus/graph"

而不是当前失败
http://myserverurl/prometheus” -> “http://myserverurl/graph”(失败)

反向代理后,URL 被重定向,/promethus 消失。

在 Grafana 设置中,我能够添加类似

的选项

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

这允许我通过
访问 Grafana 控制台 “http://myserverurl/grafana” -> “http://myserverurl/grafana/login”(成功)

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

Docker 状态:
docker run -d --name prometheus -p 9090:9090 prom/prometheus


经测试的 proxypass 配置:(无效)
ProxyPass /prometheus http://0.0.0.0:9090/prometheus
ProxyPassReverse /prometheus http://0.0.0.0:9090/prometheus

行动:
试图访问“http://myserverurl/prometheus

结果失败:
找不到 404 页面

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

但如果我将配置更改如下:
ProxyPass / http://0.0.0.0:9090/
ProxyPassReverse / http://0.0.0.0:9090/

访问网址“http://myserverurl/”->“http://myserverurl/graph

结果成功:
================================================== ======================
还尝试了以下组合 - 不起作用:
ProxyPass /promethus/ http://0.0.0.0:9090/
ProxyPassReverse /promethus/ http://0.0.0.0:9090/

【问题讨论】:

    标签: linux apache docker reverse-proxy prometheus


    【解决方案1】:

    为了让 prometheus 自己监听 /prometheus 而不是 / 你需要添加一个运行时参数:

    --web.route-prefix="prometheus"

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

    (至少在二进制 prometheus-2.7 中)

    普罗米修斯调用:

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

    并添加对称 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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-10-24
      • 1970-01-01
      • 2023-04-01
      • 2018-01-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多