grafana部署参考:https://segmentfault.com/a/1190000039654079?utm_source=sf-similar-article
使用nginx做前置转发入口,指定二级路径:
upstream grafana {
server grafana-ip:3000;
keepalive 1800;
}
location /grafana {
proxy_set_header Host "www.monitor.com";
proxy_set_header X-Forwarded-For $http_x_forwarded_for;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_pass http://${grafana }${request_uri};
}
需要修改grafana服务的几个配置项,参考 https://segmentfault.com/a/1190000016235824
修改配置文件 ./conf/defaults.ini 中的如下配置,域名和 url二级目录 修改为与nginx配置中一致
# The public facing domain name used to access grafana from a browser. 默认为 0.0.0.0。使用nginx做为前置服务入口时,这里的域名需要对应修改为一致。
domain = www.monitor.com
# The full public facing url. 默认不带二级目录。url二级目录的修改,需要与nginx保持一致
root_url = %(protocol)s://%(domain)s:%(http_port)s/grafana/
# Serve Grafana from subpath specified in `root_url` setting. By default it is set to `false` for compatibility reasons. 默认值为 false。修改了root_url增加二级目录时,这里需要修改为true。
serve_from_sub_path = true
修改后启动grafana:
/opt/grafana/bin/grafana-server web
浙公网安备 33010602011771号