在nginx和apache代理后面配置grafana
时间:2020-02-23 14:38:13 来源:igfitidea点击:
在本教程中,将介绍如何将Grafana部署在Nginx和Apache Web服务器后面,以代理所有访问请求。
一旦我们拥有Grafana安装nginx Web服务器。
### Install Nginx on Ubuntu | Debian ### $sudo apt update $sudo apt install nginx ### Istall Nginx on CentOS ### $sudo yum -y install epel-release $sudo yum -y install nginx
启动并启用Nginx服务:
sudo systemctl enable nginx sudo systemctl start nginx
Grafana背后nginx.
如果使用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:
$sudo nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful $sudo systemctl restart nginx
Grafana背后apache.
如果我们正在运行Apache Web服务器,则可以使用类似于下面的配置添加VirtualHost:
<VirtualHost *:80> DocumentRoot /var/www/html/ ServerAdmin Hyman@theitroad 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服务器:
$sudo apachectl -t Syntax OK