Self-host Directus
Wraps an SQL database with REST and GraphQL APIs and a visual management Studio, used as a headless CMS or backend. Run your own Directus on an always-on EnvHaven workspace by asking its coding agent: one request installs it, puts it on an HTTPS address and locks it down. What the agent takes care of, and the manual route.
Updated November 23, 2026
Running your own Directus usually means a list of server chores: a machine that stays on, Docker or a runtime, a reverse proxy with certificates, a domain, and the settings that make Directus behave behind all of it. On an EnvHaven workspace you skip the list. You ask the coding agent, and it does the work while you watch.
Just ask your agent
Open a Plus workspace (Directus runs in Docker, which Plus and Pro include), tap Launch to start any coding agent (Claude Code, Codex, OpenCode or another), and ask it:
Set up Directus on this workspace and give me the link. Follow https://envhaven.com/self-host/directus.md
Then open the link it sends and create your Directus account straight away, before anyone else finds the address. That is the whole request: the address in it is this page’s Markdown copy, and the agent follows the instructions for it further down, with every setting Directus’s docs require.
Or keep it private with Tailscale
The preview URL puts Directus on the public internet, which suits something other people need to reach. For an app only you and your household use, your tailnet is the better home: Tailscale gives Directus an HTTPS address that only your own devices, signed in to your Tailscale account, can open. Save a Tailscale auth key in the workspace’s Vars pane as TS_AUTHKEY, and ask the agent:
Set up Directus on my tailnet instead of the preview URL. Follow https://envhaven.com/self-host/directus.md and https://envhaven.com/guides/self-host-privately-with-tailscale.md
- A Tailscale container runs beside Directus, so it keeps its private address through workspace restarts and updates, and every app you set up this way gets an address of its own.
- Anything other services have to reach, such as a webhook, still needs a public address. Keep self-hosted apps private with Tailscale covers both, and what Tailscale’s free plan includes.
| At a glance | |
|---|---|
| What it is | Databases, backends and analytics |
| License | MSCL-1.0-GPL |
| Runs as | Docker (directus/directus) |
| Memory | 512 MB required minimum per container; 2 GB per instance recommended (docs) |
| Plan that fits | Plus or larger |
| Web port | 8055 |
| Documentation | directus.com/docs/self-hosting/deploying |
What your agent takes care of
- Installing it. Directus runs from the official image,
directus/directus, with its data in folders under~/apps/directus. - Putting it on an HTTPS address. The workspace’s preview URL serves it, and your own domain can too.
- Locking it down first. What Directus’s docs say to set before it faces the internet, below.
- Telling you what to back up: the database (external server, or the SQLite file at DB_FILENAME, for example ./database:/directus/database), ./uploads:/directus/uploads (local file storage) and ./extensions:/directus/extensions (docs).
The settings it needs behind a proxy
PUBLIC_URL: Public address of the API; used for OAuth redirects, password-reset emails and public logos. Default /. Must be a valid absolute URL before a license key can be activated. (docs)PUBLIC_URLand licensing: Absolute URL is required for license activation; changing it later means re-applying the license. (docs)SESSION_COOKIE_SECUREandREFRESH_TOKEN_COOKIE_SECURE: Secure attribute on the session and refresh cookies; both default to false, so set them to true behind HTTPS. (docs)SESSION_COOKIE_SAME_SITEandREFRESH_TOKEN_COOKIE_SAME_SITE: SameSite value of the cookies (default lax); relevant when the front end runs on another origin. (docs)SESSION_COOKIE_DOMAINandREFRESH_TOKEN_COOKIE_DOMAIN: Cookie domain, empty by default. (docs)IP_TRUST_PROXY: Passed to Express trust proxy; default false, so client IPs behind a proxy need it set. (docs)CORS_ENABLEDandCORS_ORIGIN: CORS headers are off by default; enable and list the front-end origins when a browser app calls the API cross-origin. (docs)WEBSOCKETS_ENABLED: WebSocket support (realtime, subscriptions) is disabled by default; if enabled, the proxy must pass Upgrade headers to /websocket. (docs)PASSWORD_RESET_URL_ALLOW_LIST: URLs allowed as reset_url in password-reset requests. (docs)
Before it faces the internet
- The first visitor to a fresh instance is guided through creating the first admin account, so open the Studio and finish onboarding before exposing it, or pre-set ADMIN_EMAIL and ADMIN_PASSWORD. (docs)
- Scripted setups can seed the first admin. (docs)
- The docs’ compose example uses placeholder secrets and the database password directus; replace them. (docs)
- A SECRET must be set (the docs’ minimum configuration is a database plus SECRET); the config reference lists its default as a random value. (docs)
- Cookies are not marked Secure by default. (docs)
- Per-IP rate limiting is off by default. (docs)
Things to ask next
Everything after the install is one more sentence to the agent. Some that come up:
- “Create the tables for a simple CRM: companies, contacts and deals.”
- “Seed it with sample data so I can try the interface.”
- “Move Directus to app.example.com.” Add the domain on the dashboard’s Domains page with a CNAME to
domains.envhaven.app, and the agent changes Directus’s address settings to match. - “Update Directus to the latest release.” It pulls the new image and recreates the container, data kept.
Instructions for the agent
The agent reads these from the page’s Markdown copy. They also work pasted on their own, if you would rather give them in your own words.
Set up Directus on this workspace and serve it at my preview URL.
- Use Docker Compose with the official image, directus/directus, starting from the docs' compose file: https://directus.com/docs/self-hosting/deploying. If `docker compose` is missing, install the Compose plugin into ~/.docker/cli-plugins first.
- The docs' setup includes: a database of your choice: PostgreSQL (PostGIS in the docs example), MySQL, MariaDB, MS SQL Server, CockroachDB, OracleDB, or SQLite as a file with no extra service; Redis (optional: recommended for caching, required to scale horizontally).
- Keep the compose file in ~/apps/directus and all of its data in folders there (bind mounts, not named volumes), with restart: unless-stopped on every service.
- This server has no firewall, so publish no port on its public IP, and drop host networking and privileged mode from the docs' compose file. Docker runs on the host: connect this workspace to the compose network and relay my preview URL's port to Directus's port 8055.
- The preview URL terminates HTTPS in front of Directus: serve plain HTTP on its port, and trust the forwarded headers the relay passes on.
- Set what "The settings it needs behind a proxy" lists on https://envhaven.com/self-host/directus.md for the preview URL, as Directus's docs describe for running behind a proxy; skip any that apply only when Directus serves HTTPS itself.
- Before the preview URL serves it, apply what "Before it faces the internet" lists on https://envhaven.com/self-host/directus.md.
- When it answers at the preview URL, send me the link and tell me what to back up.
- If I asked for my tailnet instead of the preview URL, set Directus up the same way but follow https://envhaven.com/guides/self-host-privately-with-tailscale.md for the network: no preview URL, no relay.
What to know
- In Docker, Directus’s containers keep running when the workspace restarts or updates. The relay from the preview URL is a process in the workspace, so after a restart or an update, ask the agent to restore it.
- Without a license a self-hosted instance runs on the core tier, which is capped at 3 users, 25 collections and 5 flows (limits are on the pricing page). (docs)
- The core tier needs no license and can run air-gapped; with a license key Directus calls the licensing service over outbound HTTPS and revalidates at least every 12 hours. (docs)
- Telemetry is on by default and opting out depends on the license. (docs)
- Request bodies and incoming WebSocket messages are capped at 1mb by default (MAX_PAYLOAD_SIZE); file uploads have no default cap (FILES_MAX_UPLOAD_SIZE empty), so set one below a 100 MB tunnel limit. (docs)
- Email transport defaults to sendmail; set EMAIL_TRANSPORT to smtp, mailgun, ses or mailtrap and the matching host settings. (docs)
- Docker containers lose changes on restart unless volumes are mounted. (docs)
- MSCL excludes Competing Use and converts each version to GPL-3.0 four years after release. (docs)
- A workspace has one preview URL and one custom domain, both serving the same port, so it puts one app on a public address at a time.
Without a workspace
The manual route, on a server you run:
- Rent a Linux VPS, secure SSH, and create a user for the app.
- Install Docker and write a compose file from the official image.
- Put a reverse proxy in front (Caddy, nginx or Traefik), get certificates, and point a domain at the server.
- Set the proxy settings listed above for that domain, and pass WebSocket upgrades through the proxy if the app uses them.
- Keep the firewall closed except for the proxy, and schedule backups and updates.
Directus’s own documentation covers each step for its install methods.
Sources
Facts about Directus come from its own documentation, checked on 2026-11-23:
- directus.com/docs/self-hosting/deploying
- directus.com/docs/self-hosting/requirements
- directus.com/docs/configuration/general
- directus.com/docs/licensing/overview
- directus.com/docs/configuration/security-limits
- directus.com/docs/configuration/realtime
- directus.com/pricing
- directus.com/docs/configuration/email
- github.com/directus/directus/blob/main/license