We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Learn how to – Configure Grafana behind Nginx and Apache Proxy

Learn how to – Configure Grafana behind Nginx and Apache Proxy.

In this guide, I’ll show you how to deploy Grafana behind Nginx and Apache web server to proxy all access requests. This configuration assumes you have a ready Grafana installation, refer to our guide on how to Install Grafana:

Once you have Grafana install Nginx Web Server.

### 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

Start and enable nginx service:

sudo systemctl enable nginx
sudo systemctl start nginx

Configure Grafana behind Nginx proxy

If you are using Nginx as your web server, the configuration will differ from one for Apache. Create nginx configuration file with content like below.

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;

}

If you have ssl enabled, add:

listen 443 ssl; 
    ssl_certificate /certpath
    ssl_certificate_key  /certkeypath

Confirm configuration syntax and restart 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 behind Apache proxy

In case you are running an Apache web server,  you can add a VirtualHost with a configuration similar to below:

<VirtualHost *:80>
DocumentRoot /var/www/html/
ServerAdmin webmaster@domain.com
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>

Confirm that configuration is fine and restart apache server:

$ sudo apachectl -t
Syntax OK

Check other articles on Grafana:

Cart

Your Cart is Empty

Back To Shop