---
title: "Self-host Directus on Edge | Instant API over SQL"
description: "Run Directus on a real VM over Postgres or any SQL database, with S3-compatible file storage and a global CDN for API responses and assets. Zero egress fees."
url: https://edge.network/solutions/directus
---

For Directus

# Directus on Edge: any database, instant API

Wrap a SQL database in a polished admin app and a REST and GraphQL API. Run it on a real VM, keep files in S3-compatible storage and serve assets from 988 locations.

[Deploy a VM](/console/access/new?product=compute)[Read the deploy guide](/docs/compute/getting-started)

The setup on this page costs $40.73 a month, with no egress line.

Why Directus on Edge

## Real database, real storage, real network

Everything Directus needs to run in production, without paying SaaS multiples for any of it.

-   ### Bring your own SQL database
    
    Postgres, MySQL, MariaDB, SQLite or MS SQL. Directus mirrors the schema and exposes a REST and GraphQL API.
    
-   ### An S3-compatible file library
    
    Set the STORAGE\_\* variables and uploads, thumbnails and exports land in an Edge Storage bucket.
    
-   ### Transforms at the edge
    
    Directus has its own asset transforms. For busy sites, hand the work to the CDN and cache every variant.
    
-   ### Flows without time-outs
    
    Automation flows and webhooks run on a real VM. No serverless execution limits to work around.
    
-   ### A global CDN for the API
    
    Cache GETs in 988 locations and mutate at the origin, with no egress on the way out.
    
-   ### Your agent can stand it up
    
    The Edge agent API can stand up Directus, point a domain at it and create the file bucket from one prompt.
    

Reference architecture

## Directus and Postgres, split over a private network

Directus on one VM, Postgres on another over a private network, files in object storage and the CDN out front.

-   [Compute](/compute)
    
    Runs Directus (Node.js) and a separate Postgres VM.
    
-   [Storage](/storage)
    
    The s3 storage location for the file library.
    
-   [CDN](/cdn)
    
    Caches public API responses and asset URLs worldwide.
    
-   [Image optimisation](/docs/cdn/image-optimization)
    
    Optional: replace Directus asset transforms with edge processing.
    
-   [DNS](/dns)
    
    Anycast DNS for the API subdomain.
    
-   [Shield](/shield)
    
    Checks public form endpoints with a humanity score before they write.
    
-   [Assist](/assist)
    
    AI answers on the sites your Directus data powers.
    

Deploy

## Two VMs and a bucket, then query it

Two VMs on a private network, one bucket and the CDN. Attach both VMs to the same private network from the Networking tab.

1.  01
    
    ### Create the database and app VMs
    
    The postgresql script installs PostgreSQL 16 with remote access. A security group keeps port 5432 on the private range.
    
    shell
    
    ```
    $ edge compute create --name directus-db --size s-2vcpu-4gb \
        --image ubuntu-24 --region london --script postgresql \
        --script-param db_name=directus
    $ edge compute groups create --name pg-private
    $ edge compute groups add-rule grp-abc123 --port 5432 \
        --protocol tcp --source 10.0.0.0/8
    
    $ edge compute create --name directus --size s-2vcpu-4gb \
        --image ubuntu-24 --region london --script nodejs
    $ edge storage create directus-files
    ```
    
2.  02
    
    ### Configure the database and storage
    
    Directus reads everything from the environment. The s3 driver takes a custom endpoint and path-style addressing.
    
    .env
    
    ```
    PUBLIC_URL="https://cms.acme.io"
    SECRET="..."
    
    DB_CLIENT="pg"
    DB_HOST="10.0.0.3"
    DB_PORT="5432"
    DB_DATABASE="directus"
    DB_USER="postgres"
    DB_PASSWORD="..."
    
    STORAGE_LOCATIONS="edge"
    STORAGE_EDGE_DRIVER="s3"
    STORAGE_EDGE_KEY="..."
    STORAGE_EDGE_SECRET="..."
    STORAGE_EDGE_BUCKET="directus-files"
    STORAGE_EDGE_REGION="us-east-1"
    STORAGE_EDGE_ENDPOINT="https://storage.edge.network"
    STORAGE_EDGE_FORCE_PATH_STYLE="true"
    ```
    
3.  03
    
    ### Install and run it as a service
    
    bootstrap migrates the database and creates the first admin. systemd keeps it running and restarts it after upgrades.
    
    shell
    
    ```
    $ cd /srv/directus && npm install directus
    $ npx directus bootstrap
    $ sudo tee /etc/systemd/system/directus.service <<'EOF'
    [Service]
    WorkingDirectory=/srv/directus
    ExecStart=/usr/bin/npx directus start
    Restart=always
    
    [Install]
    WantedBy=multi-user.target
    EOF
    $ sudo systemctl enable --now directus
    ```
    
4.  04
    
    ### Put the CDN in front
    
    Cache public reads with a short TTL. Writes and authenticated requests pass through to the VM.
    
    shell
    
    ```
    $ edge cdn create --name acme-cms
    $ edge cdn domains add cdn-a1b2c3 --domain cms.acme.io \
        --origin https://<vm-ip> --cache-ttl 60
    ```
    
5.  05
    
    ### Query it from your front end
    
    Directus's own asset transforms use width, quality and format too, so the URLs read the same either way.
    
    lib/directus.ts
    
    ```
    import { createDirectus, rest, readItems } from '@directus/sdk'
    
    const directus = createDirectus('https://cms.acme.io').with(rest())
    
    export const articles = await directus.request(
      readItems('articles', { fields: ['id', 'title', 'cover'] }),
    )
    // <img src={`https://cms.acme.io/assets/${a.cover}?width=800`} />
    ```
    

Prefer to hand it off? [Give the job to your AI agent](/solutions/agentic-development) or [have our engineers do it](/solutions/expert-services).

What it costs

## An instant API with a fixed monthly cost

An app VM, a database VM, a CDN deployment and a bucket. No per-seat, per-item or per-request pricing on the Directus side.

-   Free bandwidth between VMs on a private network
-   File delivery at $0 egress
-   Root on both VMs, full database access

[See compute pricing](/compute/pricing)

Estimated monthly bill on Edge

Directus + Postgres on separate VMs, ~3.5M requests/mo, 105 GB of files

USD

-   Compute (app)$19.24Standard VM, 2 vCPU, 4 GiB, Directus
-   Compute (database)$19.24Standard VM, 2 vCPU, 4 GiB, PostgreSQL 16
-   CDN$0.753.5M requests: 500k free, then 3M × $0.25 per million
-   Storage$1.50105 GB of files: 5 GB free, then 100 GB × $0.015
-   DNS$0.00API subdomain
-   Egress$0.00

Total$40.73

FAQ

## Data, extensions and where flows run

Something else? [Ask an engineer](/contact).

Self-hosted or Directus Cloud?

Directus Cloud is the official managed service. Self-hosting on Edge gives you root, custom extensions and full control of your database, in exchange for running a VM yourself.

Can I point Directus at an existing database?

Yes, and it's arguably the best feature. Directus introspects your existing schema and puts an admin app and an API on top, without forcing a migration.

Where do flows and webhooks run?

On the Directus VM for everyday volumes. For heavy automation, run a second Directus instance as a worker on the same private network, connected to the same database.

How do I deploy custom extensions?

Ship the extensions folder with git and restart the systemd service. If you prefer containers, build a Docker image and follow the Docker stack pattern instead.

Drop-in services

## Protect what writes to your database

-   [
    
    Edge ShieldBot protection`POST /siteverify → score: 94`
    
    Guard public form endpoints with a humanity-score check before anything is written to the database.
    
    Free forever, with unlimited widgets. No puzzles for visitors.Explore
    
    ](/shield)
-   [
    
    Edge AssistAI answers`<script src="…/assist.js">`
    
    Whatever site your Directus data powers, Assist answers visitors from it.
    
    Free tier: 250 answered questions a monthExplore
    
    ](/assist)

Related stacks

## Headless peers, and the Postgres underneath

[All 38 stacks](/solutions/stacks)

-   [PayloadTypeScript-first headless CMS, Next.js-ready](/solutions/payload)
-   [StrapiThe leading open-source headless CMS](/solutions/strapi)
-   [PostgreSQLSelf-hosted Postgres on dedicated NVMe](/solutions/postgresql)
-   [DockerRun any container on global VMs](/solutions/docker)

## Turn your database into an API this week

Start free. Bring an existing database or scaffold a fresh project.

[Deploy a VM](/console/access/new?product=compute)[Talk to an engineer](/contact)

Billed hourly from a prepaid balance. Egress is free on every product.
