This step-by-step guide shows you how to install and secure Metabase on a DigitalOcean Droplet using Docker. You’ll connect it to a managed PostgreSQL database, use your own domain, set up HTTPS with Certbot, and learn how to keep Metabase up to date. Perfect for teams that want fast, self-hosted analytics! π
π§° What You Need
- π Domain name pointed to your Droplet IP
- βοΈ DigitalOcean Droplet running Ubuntu 22.04+
- π³ Docker installed on the Droplet
- π’οΈ Managed PostgreSQL cluster from DigitalOcean
π§ 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 now have a secure, scalable Metabase setup on DigitalOcean! Use this setup to build dashboards, run queries, and give your team the data insights they need. π§ π‘