1. cat /usr/local/grafana/conf/defaults.ini
# The full public facing url
#root_url = %(protocol)s://%(domain)s:%(http_port)s/
root_url = http://localhost:3000/mygrafana/ # 这里要跟外面的url对应上
# url是: https://cyxttest.doonen.net/mygrafana/
2. nginx 的server的配置
location /mygrafana/{
proxy_pass http://localhost:3000/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
参考: 如何将 Nginx 配置为 Grafana 服务器的反向代理-之路教程 (onitroad.com)
用一个例子来演示会更加清晰