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 /promethues/ { 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; } }
接下来需要的是将prometheus和grafana在启动或者配置文件中做一些更改,prometheus的相对来说比较简单,主要实在启动的时候根据命令行的参数来进行子路径设置。
在启动的时候设置web.external-url
使用下面的命令:
./prometheus --web.external-url=prometheus --config.file=prometheus.yml
启动服务,结果如图:
grafana的代理需要在default.ini
中配置
# The full public facing url root_url = %(protocol)s://%(domain)s:%(http_port)s/grafana
重启服务,结果如图:
Prometheus + Grafana(七)nginx 设置反向代理
原文:https://www.cnblogs.com/caoweixiong/p/12155712.html