Prometheus + Grafana(三)nginx 設置反向代理


 

1.nginx 設置

server {
    listen       127.0.0.1:80;
    #server_name  localhost;
    #charset koi8-r;
    #access_log  logs/host.access.log  main;
    location / {
        root   html;
        index  index.html index.htm;   
    #    proxy_pass http://127.0.0.1:9090/;
    }
 location /grafana/ { proxy_pass http://10.xx.xxx.55:3000/; } location /prometheus/ { proxy_pass http://10.xx.xxx.55:9090/prometheus/;  }
    #error_page  404              /404.html;
    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }
}

 

 

2.設置prometheus子路徑

接下來需要的是將prometheus和grafana在啟動或者配置文件中做一些更改,prometheus的相對來說比較簡單,主要實在啟動的時候根據命令行的參數來進行子路徑設置。

在啟動的時候設置web.external-url使用下面的命令:

./prometheus --web.external-url=prometheus --config.file=prometheus.yml

 啟動服務,結果如圖:

 

  

3.設置grafana子路徑

grafana的代理需要在default.ini中配置

# The full public facing url
root_url = %(protocol)s://%(domain)s:%(http_port)s/grafana

 重啟服務,結果如圖:


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM