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:

Install Grafana on Ubuntu | Debian

Install Grafana on CentOS Linux

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

Grafana behind Nginx

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

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 [email protected]
   ProxyPreserveHost On
   ProxyPass / http://localhost:3000/
   ProxyPassReverse / http://localhost:3000/
   ErrorLog logs/grafana_error_log
   TransferLog logs/grafana_access_log

Confirm that configuration is fine and restart apache server:

$ sudo apachectl -t
Syntax OK

Check other articles on Grafana:

Monitor Apache Kafka with Prometheus and Grafana

How To Monitor Etcd Cluster with Prometheus and Grafana

How to Monitor Linux Server with Netdata and Grafana

Your support is our everlasting motivation,
that cup of coffee is what keeps us going!

As we continue to grow, we would wish to reach and impact more people who visit and take advantage of the guides we have on our blog. This is a big task for us and we are so far extremely grateful for the kind people who have shown amazing support for our work over the time we have been online.

Thank You for your support as we work to give you the best of guides and articles. Click below to buy us a coffee.


Please enter your comment!
Please enter your name here