Make Gadgets Work

Metabase - A BI solution that just works

Ankit Mittal

I like exploring new solutions and anything to do with data always piques my interest. I came across this nice tool through the list of free self hosted software.

The overall impression when I opened their site can be summed up with WOW!! Now they offer simple docker install supported officially by them and the guide to install docker image is simple enough but the few simple steps I followed are as below:

  1. Create an A-record for a subdomain for metabase
  2. Download the official metabse docker image from dockerhub
  3. Create an apache server conf file for metabase
  4. Run the metabase docker image
  5. Access metabase docker image using subdomain URL
  6. Configure your database on metabase
  7. Run Certbot to make the URL https
  8. Done!!

Create A-record for subdomain

Using the process for your Domain Name Regsitrar create an A-Record for a subdomain you would want to use for metabase. For this guide we will assume that the subdomain being created is called "metabase" so if your domain name is say then the URL to access metabase will be metabase .yourdomain .com.

NOTE: It is important that if you use a different subdomain name, please replace metabase with the subdomain name you have chosen in all Apache conf file samples in sections below.

More detailed steps are available on previous post HERE

Download and Create Apache Conf

docker pull metabase/metabase
cd /etc/apache2/sites-available/
sudo nano metabase.conf

Create a conf file similar to what is shown below:

<VirtualHost *:80>

    ErrorLog ${APACHE_LOG_DIR}/error_metabase.log
    CustomLog ${APACHE_LOG_DIR}/access_metabase.log combined

    ProxyPreserveHost On
    ProxyPass / http://localhost:3000/
    ProxyPassReverse / http:/localhost:3000/
    ProxyPass "/ws2/"  "ws://localhost:3000/"
    ProxyPass "/wss2/" "wss://localhost:3000/"

Save this by pressing Ctrl+X and issue following commands to enable site and reload the apache server.

 sudo a2ensite metabase.conf
 sudo systemctl reload apache2

Run Metabase docker image

docker run -d -p 3000:3000 --name metabase metabase/metabase

If all goes well, you should have metabase already running. If you get an error to the effect saying port 3000 is already in use, you will perhaps have to run it on another port (say 12345) but as metabase image would have been created you will need to issue following commands:

docker rm metabase
docker run -d -p 12345:3000 --name metabase metabase/metabase

Do bear in mind if you have to do this, you will also need to change the port in apache conf file in previous step. So your apache conf file in this case will look as shown below:

<VirtualHost *:80>

    ErrorLog ${APACHE_LOG_DIR}/error_metabase.log
    CustomLog ${APACHE_LOG_DIR}/access_metabase.log combined

    ProxyPreserveHost On
    ProxyPass / http://localhost:12345/
    ProxyPassReverse / http:/localhost:12345/
    ProxyPass "/ws2/"  "ws://localhost:12345/"
    ProxyPass "/wss2/" "wss://localhost:12345/"

Access and configure on browser

Access your metabase using the subdomain url - http:// metabase .yourdomain .com and it should walk you through the initial configuration. If you do not want to add a database and just play with the tool, they have kindly provided a sample database.

Enable SSL

Once you are happy with your configuration from step above, just run the certbot to enable https using letsencrypt certificate. On Debian this could be as simple as issuing the command

sudo certbot

Once above step is created you will have an additional conf file named metabase-le-ssl.conf created in the location /etc/apache2/sites-available. Check this and once it is there you are all set to access your new funstional metabase instance on https.

More detailed steps are availble on previos post HERE