Docs / Self-Hosted Applications / Self-Host Supabase

Self-Host Supabase

By Admin · Mar 15, 2026 · Updated Apr 24, 2026 · 415 views · 2 min read

What is Supabase?

Supabase is an open-source Firebase alternative providing a PostgreSQL database, authentication, instant APIs, real-time subscriptions, storage, and edge functions. Self-hosting gives you full control over your data and no usage limits.

Docker Installation

git clone --depth 1 https://github.com/supabase/supabase /opt/supabase
cd /opt/supabase/docker

cp .env.example .env
# Edit .env - set these critical values:
# POSTGRES_PASSWORD (strong random password)
# JWT_SECRET (min 32 chars)
# ANON_KEY and SERVICE_ROLE_KEY (generate JWT tokens)
# SITE_URL=https://app.example.com
# API_EXTERNAL_URL=https://supabase.example.com

docker compose up -d

Components

  • PostgreSQL: Core database with Row Level Security
  • GoTrue: Authentication server (email, OAuth, magic links)
  • PostgREST: Auto-generated REST API from your database schema
  • Realtime: WebSocket server for live data subscriptions
  • Storage: S3-compatible file storage with RLS policies
  • Kong: API gateway and routing
  • Studio: Web-based database management UI

Nginx Reverse Proxy

server {
    listen 443 ssl http2;
    server_name supabase.example.com;
    location / {
        proxy_pass http://127.0.0.1:8000;
        proxy_set_header Host $host;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}

Using with Your Application

import { createClient } from "@supabase/supabase-js"

const supabase = createClient(
    "https://supabase.example.com",
    "your-anon-key"
)

// Query data
const { data } = await supabase.from("posts").select("*")

// Authentication
await supabase.auth.signUp({ email, password })

// Real-time subscription
supabase.channel("posts").on("postgres_changes",
    { event: "*", schema: "public", table: "posts" },
    (payload) => console.log(payload)
).subscribe()

Best Practices

  • Use strong, unique JWT secrets and database passwords
  • Enable Row Level Security on all tables
  • Set up automated PostgreSQL backups
  • Monitor disk space for storage uploads
  • Keep Supabase updated with docker compose pull

Was this article helpful?