Installing Grafana with Nginx on AlmaLinux

By Jennifer Mathew

Updated on May 18, 2024

In this tutorial, we'll discuss about installing Grafana with Nginx on AlmaLinux 8 and securing with SSL.

Grafana an open-source analytics and monitoring platform that allows you to visualize and analyze data from various sources. It supports a wide range of data sources including databases, cloud services, and custom applications.

With Grafana, you can create interactive dashboards to monitor, analyze, and understand your data in real-time.


Before you begin, ensure you have the following prerequisites:

  • AlmaLinux 8 installed dedicated server.
  • A user account with sudo privileges
  • Basic knowledge of the Linux command line

1. Update the system:

sudo dnf update -y

2. Install Grafana

Add the Grafana repository:

sudo vim /etc/yum.repos.d/

Note: Replace with your domain name.

Add the following lines to the file:


Install Grafana:

sudo dnf install -y grafana

Start and enable the Grafana service:

sudo systemctl start grafana-server
sudo systemctl enable grafana-server

Check Grafana status:

sudo systemctl status grafana-server

3. Install and Configure Nginx

Install Nginx:

sudo dnf install -y nginx

Start and enable Nginx service:

sudo systemctl start nginx
sudo systemctl enable nginx

Configure Nginx as a reverse proxy:

sudo vim /etc/nginx/conf.d/

Note: Replace with your domain name.

Add the following configuration:

server {
    listen 80;

    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;
        proxy_set_header X-Forwarded-Proto $scheme;

Note: Replace with your actual domain name or server IP address.

Test Nginx configuration:

sudo nginx -t

Reload Nginx to apply the changes:

sudo systemctl reload nginx

4. Configure Firewall

Allow Nginx through the firewall:

sudo firewall-cmd --zone=public --add-service=http --permanent
sudo firewall-cmd --zone=public --add-service=https --permanent
sudo firewall-cmd --reload

Configure SELinux (Optional)

(If you have enabled SELinux, follow this step or else you can skip it.)

We need to configure SELinux to allow Nginx to connect to network services.

sudo setsebool -P httpd_can_network_connect 1

If you are still get an erro 500 or something like that, add tcp 3000 port in SELinux using following command:

sudo semanage port -a -t http_port_t -p tcp 3000

If you are still getting error or unable to access Grafana, disable SELinux and check.

5. Secure Grafana with HTTPS

Install Certbot (Let's Encrypt client):

sudo dnf install -y certbot python3-certbot-nginx

Obtain and install the SSL certificate:

sudo certbot --nginx -d

Note: Replace with your domain name.

Follow the prompts to complete the SSL installation. Certbot will automatically configure Nginx for SSL.

Set up a cron job for auto-renewal:

echo "0 0,12 * * * root certbot renew --quiet" | sudo tee -a /etc/crontab > /dev/null

6. Access Grafana

Open your web browser and navigate to your server's domain or IP address:

Log in to Grafana using the default credentials:

Username: admin
Password: admin

You will be prompted to change the default password after the first login.

By following these steps, you will have Grafana running behind Nginx on AlmaLinux.


In this tutorial, we have discussed about installing Grafana with Nginx on AlmaLinux 8 & securing with SSL. Grafana is a powerful tool for monitoring and analyzing data, and with its flexible and intuitive interface, you can create insightful dashboards to gain valuable insights from your data.