[转帖]Grafana背后的Nginx和Apache Proxy

Grafana背后的Nginx和Apache Proxy

https://ywnz.com/linuxyffq/5590.html

这个网站貌似非常非常好

在本文中,我将向你展示如何在Nginx和Apache Web服务器之后部署Grafana来代理所有访问请求,此配置假设你已准备好Grafana安装,请参考在CentOS 7上安装Grafana的方法在Ubuntu 18.04系统中安装Grafana 6的方法

Nginx背后的Grafana

如果你使用Nginx作为Web服务器,则配置将与Apache不同,使用如下内容创建nginx配置文件:

server {

listen 80;

root /usr/share/nginx/www;

index index.html index.htm;

location / {

proxy_pass http://localhost:3000;

proxy_set_header    Host             $host;

proxy_set_header    X-Real-IP        $remote_addr;

proxy_set_header    X-Forwarded-For  $proxy_add_x_forwarded_for;

}

如果你启用了ssl,请添加:

listen 443 ssl; 

ssl_certificate /certpath

ssl_certificate_key  /certkeypath

确认配置语法并重新启动nginx:

# nginx -t

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok

nginx: configuration file /etc/nginx/nginx.conf test is successful

# service nginx restart

Apache背后的Grafana

如果你正在运行Apache Web服务器,则可以添加具有类似于以下配置的VirtualHost:

<VirtualHost *:80>

DocumentRoot /var/www/html/

ServerAdmin [email protected]

ServerName grafana.domain.com

ProxyPreserveHost On

ProxyPass / http://localhost:3000/

ProxyPassReverse / http://localhost:3000/

ErrorLog logs/grafana_error_log

TransferLog logs/grafana_access_log

</VirtualHost>

确认配置正常并重启apache服务器:

# apachectl -t

Syntax OK

至此,应该能够使用服务器主机名访问Grafana仪表板。

猜你喜欢

转载自www.cnblogs.com/jinanxiaolaohu/p/11288076.html
今日推荐