从同一网络上的另一台机器访问 Grafana

Access Grafana from another machine on the same network

我使用网站上的说明在我们拥有的服务器上安装了 Grafana。当我卷曲 http://localhost:3000/ from this specific machine I got a response back. The same if I curl http://ip-address-of-grafana-machine:3000/

但是,当我尝试从同一网络上的另一台机器卷曲 http://ip-address-of-grafana-machine:3000/ 时,出现连接超时。我尝试了所有在网上找到的方法,但我仍然遇到问题。

我认为问题与端口相关的一些非常基本的问题有关,但我无法弄清楚,因为我不是网络专家。这让我相信 Grafana 默认情况下可以从安装它的机器访问,如果您需要从另一台机器访问它,您需要进行一些更改。

我还尝试了 /etc/grafana/grafana.ini 的 [server] 部分中的所有配置属性,但我没有运气。

我是不是漏掉了一些非常基础的知识?

我使用 Apache 反向代理解决了这个问题。首先,我将以下内容添加到 /etc/apache2/sites-enabled/

下的 000-default.conf 中
ServerName http://ip-address-of-grafana-machine
RewriteEngine on
RewriteRule ^/?$ /grafana/ [R=permanent,L]
<Location "/grafana">
    ProxyPass http://localhost:3000
</Location>
ProxyPassReverse /grafana http://localhost:3000

我必须在 Apache 中启用反向代理模块才能使其正常工作(记得重新启动 Apache 以加载这些模块)。否则,Apache 将不会启动。

sudo a2enmod proxy
sudo a2enmod proxy_http
sudo systemctl restart apache2

因为,我想通过地址 http://ip-address-of-grafana-machine/grafana 访问 grafana UI(这就是为什么我在 000-default.conf 中有 /grafana 路径)我设置 grafana.ini parameter root_url found under /etc/grafana to root_url = http://ip-address-of-grafana-machine:3000/grafana (remember to remove the ; in the beginning and sure you put the port number).