Metabase is a data analyzer and visualizer tool which can connect to many types of databases.

It can do some smart analysis as well as let you write proper SQL queries to create charts and graphs.

Metabase is a Java application which can be run directly. Conversely, it can also be run via Docker.

Create metabase folder

Metabase maintains a database of it’s own from whenever the application is run. So it is best to create a folder for Metabase.

$ ~/metabase > ls
metabase.jar

Run Metabase

From the command prompt

$ ~/metabase > java -jar metabase.jar

This runs the Metabase app in the foreground in 0.0.0.0:3000 (accessible from then web directly)

Run in background

It is obviously required for Metabase to run in the background. For this –

$ ~/metabase > nohup java -jar /home/<username>/metabase/metabase.jar &

Run on localhost instead

For this we need to set the environment variable MB_JETTY_HOST to 127.0.0.1 before running Metabase.

$ ~/metabase > export MB_JETTY_HOST=127.0.0.1

Rerun Metabase once the environment variable is set to have it run on localhost:3000

Nginx configuration

Nginx configuration helps to map a subdomain to the Metabase instance

server {
  listen 80;
  listen [::]:80;

  server_name metabase.example.com;

  access_log      /var/log/nginx/metabase-access.log;
  error_log       /var/log/nginx/metabase-error.log;

  gzip on;
  client_max_body_size 10m;

  location / {
    proxy_pass http://localhost:3000;
  }
}

Run Metabase on domain subpath

Sometimes, we need to run Metabase on localhost but redirect to it via a subpath.

For example, we might want www.example.com/metabase as our main Metabase URL.

In this case, we need to set another environment variable MB_SITE_URL

$ ~/metabase > export MB_SITE_URL='https:/www.example.com/metabase/

NOTE the trailing slash at the end of the URL

Nginx configuration for subpath redirect

server {
  listen 80;
  listen [::]:80;

  server_name www.example.com;

  location /metabase/ {
    proxy_pass http://localhost:3000/;
  }
}

AGAIN NOTE the trailing slash at the end of the URL and the subpath

References

Metabase Documentation
List of environment variables