How to Deploy Metabase on DigitalOcean with Docker, PostgreSQL, NGINX, and SSL

Looking for a powerful yet easy-to-use business intelligence tool you can host yourself? This step-by-step guide will walk you through installing and securing Metabase on a DigitalOcean Droplet using Docker, connected to a managed PostgreSQL database. You’ll also learn how to use your custom domain, set up free HTTPS with Certbot, and keep Metabase up to date.
By the end of this tutorial, you’ll have a robust, secure, and self-hosted analytics platform ready to serve dashboards and visualizations for your team. 📊

✅ Prerequisites

     

  • A DigitalOcean account with billing enabled
  •  

  • A registered domain name (e.g. analytics.example.com)
  •  

  • Basic knowledge of Linux and terminal commands
  •  

  • Ubuntu 22.04+ Droplet (1 GB RAM, 1 vCPU or more)
  •  

  • SSH access to your Droplet (non-root user with sudo)
  •  

  • A managed PostgreSQL database (e.g. DigitalOcean Managed DB)
  •  

  • A valid email address (for Certbot SSL)

🔧 Step 1: Create Your Managed PostgreSQL Database

Log in to the DigitalOcean Control Panel and go to Databases → Create. Choose PostgreSQL and use these settings:

  • 📍 Host: db-postgresql-sgp1-76543-do-user-2468013-0.b.db.ondigitalocean.com
  • 🔢 Port: 25060
  • 📘 Database Name: metabase_prod
  • 👤 Username: metabase_admin
  • 🔐 Password: S8fKzEw1P@ssw0rd
  • ✅ SSL Mode: Required

🛡️ Don’t forget to whitelist your Droplet’s IP under Trusted Sources.

🐳 Step 2: Install Docker on Ubuntu

sudo apt update
sudo apt install docker.io -y
sudo systemctl enable docker
sudo systemctl start docker

📦 Step 3: Run Metabase Container

docker run -d -p 3000:3000 \
  -e "MB_DB_TYPE=postgres" \
  -e "MB_DB_DBNAME=metabase_prod" \
  -e "MB_DB_PORT=25060" \
  -e "MB_DB_USER=metabase_admin" \
  -e "MB_DB_PASS=S8fKzEw1P@ssw0rd" \
  -e "MB_DB_HOST=db-postgresql-sgp1-76543-do-user-2468013-0.b.db.ondigitalocean.com" \
  -e "MB_DB_SSL=true" \
  --name metabase \
  --restart always \
  metabase/metabase:latest

🌍 Step 4: Connect Your Domain & Install NGINX

Update your domain’s DNS records to point analytics.yourdomain.com to your Droplet’s IP. Then install NGINX:

sudo apt install nginx -y
sudo nano /etc/nginx/sites-available/metabase

Paste the config below (change the domain to yours):

server {
  listen 80;
  server_name analytics.yourdomain.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;
  }
}
sudo ln -s /etc/nginx/sites-available/metabase /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx

🔐 Step 5: Secure Your Site with SSL via Certbot

sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d analytics.yourdomain.com

🎉 You now have HTTPS with a free Let’s Encrypt certificate!

🧪 Step 6: Visit Your Metabase Dashboard

Go to https://analytics.yourdomain.com in your browser and complete the Metabase setup wizard. You’re ready to explore your data! 📈

🔄 Step 7: Update Metabase When a New Version Is Released

Keep your Metabase container fresh and secure using this method:

docker pull metabase/metabase:latest
docker stop metabase
docker rm metabase

docker run -d -p 3000:3000 \
  -e "MB_DB_TYPE=postgres" \
  -e "MB_DB_DBNAME=metabase_prod" \
  -e "MB_DB_PORT=25060" \
  -e "MB_DB_USER=metabase_admin" \
  -e "MB_DB_PASS=S8fKzEw1P@ssw0rd" \
  -e "MB_DB_HOST=db-postgresql-sgp1-76543-do-user-2468013-0.b.db.ondigitalocean.com" \
  -e "MB_DB_SSL=true" \
  --name metabase \
  --restart always \
  metabase/metabase:latest

✅ Conclusion

You’ve successfully deployed a powerful, self-hosted Metabase instance on DigitalOcean, complete with a secure connection to a managed PostgreSQL database and free HTTPS. This robust setup gives your team a reliable platform to transform raw data into actionable insights, enabling better decision-making. With Metabase, you can create interactive dashboards, generate custom reports, and empower your users to explore data visually, all within a secure and scalable environment.
Now that your analytics platform is ready, what key business questions are you looking to answer with your data?

Views: 28

Leave a Comment