Website Performance
Headless CMS Explained, and How to Host One on a VPS
By NileVPS Team · Published · 4 min read
اقرأ المقال بالعربيA traditional content management system such as WordPress does two jobs at once: it stores and edits content, and it renders the pages visitors see. A headless CMS keeps only the first job. Editors still get a friendly admin panel, but the content is delivered through an API, and any frontend you like, a website, a mobile app or a kiosk screen, fetches it and decides how to display it. This article explains how the model works, its real advantages and costs, and how to run a self-hosted headless CMS on your own VPS.
Traditional vs headless
| Traditional CMS | Headless CMS | |
|---|---|---|
| Content editing | Admin panel | Admin panel |
| Page rendering | Built in (themes, templates) | Your own frontend |
| Delivery | HTML pages | REST or GraphQL API |
| Channels | Mainly one website | Website, apps, other services |
| Developer effort | Lower to start | Higher, frontend is custom |
The "head" is the presentation layer. Removing it decouples content from design, which is the main source of both the benefits and the extra work.
When a headless CMS makes sense
Good fit:
- The same content feeds several channels, for example a website and a mobile app.
- Your team already builds frontends with frameworks such as Next.js, Nuxt, Astro or SvelteKit.
- You want a static or mostly static site for speed and security, with content pulled at build time.
- You need a structured content model (products, locations, FAQs) rather than free-form pages.
Probably not worth it:
- A small brochure site or blog where a traditional CMS with a theme does the job.
- No developer available to build and maintain the frontend.
- Editors rely heavily on visual page builders and live previews, which take extra work to replicate in a headless setup.
Popular self-hosted options
Several open-source headless CMSs can run on a single VPS:
- Strapi: Node.js, content types defined in an admin UI, REST and GraphQL APIs, supports PostgreSQL, MySQL/MariaDB and SQLite.
- Directus: wraps an existing SQL database with an admin app and APIs, which is useful when you already have a schema.
- Payload: TypeScript-first, configuration in code, integrates closely with Next.js.
- Ghost: a publishing platform with themes that also exposes a Content API, so it can be used headlessly for blogs and newsletters.
Check each project's current documentation for supported Node.js and database versions before installing.
Hosting a headless CMS on a VPS
A typical single-server layout looks like this:
Internet -> Nginx (HTTPS) -> CMS on 127.0.0.1:1337 -> PostgreSQL
-> Frontend (static files or Node app)For a small to medium project, 2 vCPU and 4 GB RAM is a comfortable starting point, because building the admin panel and running Node.js plus PostgreSQL together uses memory. You can start a server from the deploy page.
Running with Docker Compose
Containers keep the CMS, its runtime and its database versions together. Directus publishes an official image, so a minimal setup is short:
services:
db:
image: postgres:16
environment:
POSTGRES_DB: directus
POSTGRES_USER: directus
POSTGRES_PASSWORD: change-me
volumes:
- ./pgdata:/var/lib/postgresql/data
restart: unless-stopped
directus:
image: directus/directus:11
ports:
- "127.0.0.1:8055:8055"
environment:
SECRET: replace-with-a-long-random-string
DB_CLIENT: pg
DB_HOST: db
DB_PORT: 5432
DB_DATABASE: directus
DB_USER: directus
DB_PASSWORD: change-me
ADMIN_EMAIL: [email protected]
ADMIN_PASSWORD: change-me-too
PUBLIC_URL: https://cms.example.com
volumes:
- ./uploads:/directus/uploads
depends_on:
- db
restart: unless-stoppedBinding the port to 127.0.0.1 means the CMS is only reachable through Nginx, not directly from the internet. Keep real passwords in an .env file rather than in the Compose file you commit.
Nginx in front
server {
server_name cms.example.com;
client_max_body_size 50m;
location / {
proxy_pass http://127.0.0.1:8055;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}Then add HTTPS with sudo certbot --nginx -d cms.example.com.
Without Docker
For Strapi you can also run it directly with Node.js: create the project, run npm run build, start it with npm run start under a systemd service or a process manager such as PM2, and set NODE_ENV=production.
Security and operations checklist
- [ ] Admin panel on HTTPS only, strong passwords and 2FA where supported
- [ ] Public API permissions limited to the content that must be public
- [ ] API tokens for build servers stored as secrets, read-only where possible
- [ ] Database not exposed to the internet
- [ ] Regular backups of the database and the uploads folder
- [ ] CMS and dependencies updated on a schedule
For the frontend, cache API responses or build static pages so traffic spikes do not hit the CMS directly. Our guide on server-side caching covers the Nginx options.
FAQ
Is a headless CMS faster than WordPress?
Not automatically. Speed depends on the frontend. A statically generated site that pulls content from a headless CMS is usually very fast, but a poorly built client-side app can be slow. A well-cached WordPress site can also perform well.
Can I use WordPress as a headless CMS?
Yes. WordPress has a built-in REST API, and plugins add GraphQL. This is a common way to keep a familiar editor while building a custom frontend.
Do I need a separate server for the frontend?
Not necessarily. On one VPS, Nginx can serve the static frontend and proxy the CMS on a subdomain. Separate servers become useful when traffic grows or when you want the CMS isolated from public traffic.