In this tutorial, we will learn how to install Metabase with Nginx on Ubuntu. We will also configure Let’s Encrypt SSL to secure our setup. Before going towards the tutorial, first let’s see what Metabase is.
What is Metabase?
Metabase is an open-source BI tool and is freely available for users. Metabase is a business intelligence tool that can generate graphical charts, dashboards, and others. It’s a web-based application, which means you can access it on your browser, and if you have hosted it somewhere, then you can easily access it on your PC in a similar way as a website.
Install Metabase with Nginx on Ubuntu
You can install Metabase on any web server, but here we will use Nginx because Nginx is fast, uses fewer resources, and can handle multiple requests at a time.
In this tutorial, we will see
Prerequisites
- Ubuntu server with initial configuration done. You can follow our initial server setup guide for Ubuntu
Step 1 – Update the Server
The first step before configuration is to update the repositories and packages so that we get the latest packages installed. Execute the commands below to update the server packages
# sudo apt update
# sudo apt upgrade -y
Step 2 – Installing Java Development Kit
Let’s install the Java Development Kit for Metabase. Because JDK is the dependency for Metabase. Execute the command below to install the Java Development Kit
# sudo apt install openjdk-21-jdk -y
As the installation completes, let’s verify it
# java --version
Step 3 – Download and Configure Metabase
First, let’s create a directory where we will keep the Metabase installed files.
# sudo mkdir /opt/metabase
Now, let’s download Metabase. Visit the Metabase page and copy the URL for the latest package, and enter it as shown below
# cd /opt/metabase
# sudo curl -O https://downloads.metabase.com/v0.55.10/metabase.jar
Step 4 – Creating the Service File
The next step is to create a service file. This will help us in managing Metabase.
# sudo nano /etc/systemd/system/metabase.service
Copy and paste the following content into the file
[Unit]
Description=Metabase server
After=syslog.target
After=network.target
[Service]
WorkingDirectory=/opt/metabase
ExecStart=/usr/bin/java -jar /opt/metabase/metabase.jar
User=metabase
Type=simple
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=metabase
[Install]
WantedBy=multi-user.target
Save the file and exit.
Step 5 – Creating a User for Metabase
Now, let’s create a new User that will manage only the Metabase and assign the required permissions
# sudo useradd -r -s /bin/false metabase
# sudo chown -R metabase:metabase /opt/metabase
Step 6 – Install and Configure PostgreSQL
The next step is to install and configure PostgreSQL. But let’s first install it
# sudo apt install postgresql postgresql-contrib
Let’s check whether PostgreSQL is working
# sudo systemctl status postgresql
Let’s create a database for Metabase
# sudo -i -u postgres
# psql
CREATE DATABASE metabase;
Create a new database user with a password
CREATE USER metabaseuser WITH ENCRYPTED PASSWORD 'password';
Note:- You can change database name (metabase), database user(metabaseuser) and password(password) as per your wish
Let’s assign privileges to the database user
GRANT ALL PRIVILEGES ON DATABASE metabase TO metabaseuser;
exit;
Exit again to log out from the postgres user
exit;
Step 7 – Configuring Firewall
Since we are using the UFW firewall, let’s allow traffic from HTTP and HTTPS so that we can access Metabase from a browser
ufw allow http
ufw allow https
ufw reload
Step 8 – Install and Configure Nginx
Let’s install Nginx as our web server and configure it
# sudo apt install nginx -y
Create an nginx virtual host file
# sudo nano /etc/nginx/sites-available/metabase
Copy and paste the code given below
server {
listen 80;
server_name metabase.your_domain.com;
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: Change "metabase.your_domain.com" to your real domain name
Enable Nginx, restart the Nginx service, and assign the required permissions.
# sudo ln -s /etc/nginx/sites-available/metabase /etc/nginx/sites-enabled/
# sudo unlink /etc/nginx/sites-enabled/default
# sudo nginx -t
# sudo systemctl restart nginx
Note: Don't forget to run the commands given below because you may get a 502 error.
# sudo journalctl -u metabase
# sudo systemctl daemon-reload
# sudo systemctl restart metabase
Step 9 – Configure Let’s Encrypt SSL
The final step is to configure Let’s Encrypt SSL. We will use the certbot tool for the same
# sudo apt install certbot python3-certbot-nginx -y
# sudo certbot --nginx -d metabase.your_domain.com
Note: Change "metabase.your_domain.com" to your real domain name
Restart the server for all the changes to take effect.
# sudo reboot
Step 10 – Use Metabase from Browser
Now you can visit your domain on any browser and try working on it. Follow the steps shown here to set up Metabase completely.
Conclusion
With this, we have installed Metabase on our Ubuntu server.