How to Deploy Strapi 5 Headless CMS on Contabo VPS with PostgreSQL and Nginx
Contabo High-Performance Cloud VPS
Massive 4 vCPU cores, 8GB RAM, and 32TB monthly traffic. Ideal for Linux developers.
Build dynamic decoupled web applications with Strapi 5. Complete guide to self-hosting Strapi on a Contabo Cloud VPS with PostgreSQL, PM2, and Let's Encrypt SSL.
- Full API flexibility with REST and GraphQL out-of-the-box for Next.js, Nuxt, and mobile apps
- Contabo Cloud VPS 1 ($4.95/mo for 8GB RAM) easily handles Strapi's Node.js build memory spikes
- No SaaS tier limits on content types, custom roles, or database records
The Rise of Headless Architecture & Strapi 5
Monolithic CMS platforms like traditional WordPress intertwine content management with frontend presentation. In modern development, engineering teams demand headless architectures: content is managed in an intuitive administrative cockpit and delivered via clean REST or GraphQL endpoints to modern frontend frameworks like Next.js, Astro, Remix, or Flutter mobile applications.
While proprietary headless CMS solutions like Contentful or Sanity charge steep monthly enterprise subscriptions when exceeding basic API limits, Strapi 5 is a 100% open-source, customizable Node.js headless CMS. By hosting Strapi on a high-RAM Contabo Cloud VPS 1 (4 vCPU cores, 8 GB RAM, 200 GB NVMe for just $4.95/mo), you bypass all third-party API metering and retain total database control.
Step 1: VPS Hardening & Environment Preparation
Connect to your Contabo VPS via SSH and install the required build dependencies, Node.js 20 LTS, and PostgreSQL 16:
ssh root@YOUR_SERVER_IP
apt update && apt upgrade -y
apt install -y curl git build-essential ufw nginx certbot python3-certbot-nginx
# Configure UFW Firewall
ufw default deny incoming
ufw default allow outgoing
ufw allow 22/tcp
ufw allow 80/tcp
ufw allow 443/tcp
ufw enable -y
# Install Node.js 20 LTS via NodeSource
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
apt install -y nodejs
npm install -g pm2 yarn
Step 2: PostgreSQL 16 Installation & Database Setup
Production Strapi deployments require a robust relational database. SQLite is suitable only for local prototyping. Install PostgreSQL:
apt install -y postgresql postgresql-contrib
systemctl enable --now postgresql
Create an isolated database and dedicated database user for Strapi:
sudo -u postgres psql
CREATE DATABASE strapi_production;
CREATE USER strapiuser WITH ENCRYPTED PASSWORD 'StrongSecureDatabasePassword_9942!';
GRANT ALL PRIVILEGES ON DATABASE strapi_production TO strapiuser;
ALTER DATABASE strapi_production OWNER TO strapiuser;
\q
Step 3: Creating and Configuring the Strapi Project
Initialize a new Strapi project using the official CLI with PostgreSQL configuration:
cd /var/www
npx create-strapi-app@latest strapi-backend --quickstart --no-run
Edit your environment variables in /var/www/strapi-backend/.env:
cd /var/www/strapi-backend
nano .env
HOST=127.0.0.1
PORT=1337
APP_KEYS=GenerateFourCommaSeparatedRandomKeysHere==
API_TOKEN_SALT=GenerateRandomSaltHere==
ADMIN_JWT_SECRET=GenerateRandomJwtSecretHere==
TRANSFER_TOKEN_SALT=GenerateRandomTransferSaltHere==
JWT_SECRET=GenerateRandomJwtTokenHere==
# Database Configuration
DATABASE_CLIENT=postgres
DATABASE_HOST=127.0.0.1
DATABASE_PORT=5432
DATABASE_NAME=strapi_production
DATABASE_USERNAME=strapiuser
DATABASE_PASSWORD=StrongSecureDatabasePassword_9942!
DATABASE_SSL=false
Step 4: Compiling Production Admin Assets
Build the Strapi administration panel bundle for production:
NODE_ENV=production npm run build
Create an ecosystem file for the PM2 process manager:
cat << 'EOF' > ecosystem.config.js
module.exports = {
apps: [
{
name: 'strapi-api',
script: 'npm',
args: 'run start',
env: {
NODE_ENV: 'production',
},
},
],
};
EOF
Start the Strapi daemon and register systemd startup hooks:
pm2 start ecosystem.config.js
pm2 save
pm2 startup
Step 5: Nginx Reverse Proxy with Let's Encrypt SSL
Create an Nginx configuration file to route HTTPS traffic from your domain to Strapi on internal port 1337:
cat << 'EOF' > /etc/nginx/sites-available/strapi.conf
server {
server_name cms.yourdomain.com;
location / {
proxy_pass http://127.0.0.1:1337;
proxy_http_version 1.1;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $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;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
}
EOF
ln -s /etc/nginx/sites-available/strapi.conf /etc/nginx/sites-enabled/
nginx -t && systemctl reload nginx
certbot --nginx -d cms.yourdomain.com --non-interactive --agree-tos -m admin@yourdomain.com
Step 6: Onboarding and Integrating with Next.js
Visit https://cms.yourdomain.com/admin to complete the administrator onboarding wizard. Once logged in:
- Create Content Types (e.g., Articles, Categories, Authors, Testimonials).
- Under Settings > API Tokens, generate a read-only or full-access API Token.
- Query your data effortlessly from your Next.js application using standard
fetch()or GraphQL queries.
High RAM Advantage on Contabo
Strapi's automated admin build process can demand over 1.5GB of RAM during production compilation. While 1GB or 2GB cloud servers on AWS or Linode trigger out-of-memory kernel kills, Contabo's generous 8GB to 16GB RAM base handles concurrent API traffic and admin compilations without breaking a sweat.
Recommended Reading & Related Guides
Conclusion
Self-hosting Strapi 5 on a Contabo Cloud VPS delivers enterprise-grade headless capability, unlimited media uploads, localized content, and unconstrained API queries for less than $5 a month.
Video Walkthrough & Official References
Linux Nginx Reverse Proxy & SSL: Full Tutorial for Beginners • Cloud Explainers
Official External Documentation
Upstream directives for reverse proxying, FastCGI caching, and TLS termination.
Configuration parameters, indexing, and pg_dump backup strategies.
Server rescue mode, VNC console access, and Object Storage S3 endpoints.
Editorial Verdict: Pros & Cons
What We Love (Pros)
- Full API flexibility with REST and GraphQL out-of-the-box for Next.js, Nuxt, and mobile apps
- Contabo Cloud VPS 1 ($4.95/mo for 8GB RAM) easily handles Strapi's Node.js build memory spikes
- No SaaS tier limits on content types, custom roles, or database records
Drawbacks (Cons)
- Initial production build requires at least 2GB of free RAM during TypeScript transpilation
Deploy Your Contabo Cloud Server
Includes 4 vCPU Cores, 8GB RAM, 50GB NVMe SSD, and 32TB Outbound Traffic.
Written by Marcus Vance
Full-Stack Cloud Engineer
Alex and the ServerCraft engineering lab run routine benchmarks on over 25 web hosting providers, maintaining strict objectivity and reproducibility.
Recommended Next Reads
How to Set Up Free Let's Encrypt SSL with Certbot & Nginx on Ubuntu
A complete guide to provisioning automated Let's Encrypt SSL/TLS certificates using Certbot on Ubuntu 24.04 and Nginx. Includes HTTP/2 and A+ SSL Labs rating configuration.
How to Set Up PostgreSQL 16 & pgAdmin 4 on Ubuntu VPS (Hardened Guide)
A production walkthrough for deploying PostgreSQL 16 and pgAdmin 4 with SSL encryption, role-based access control, and automated daily database dumps.
How to Set Up Nginx Reverse Proxy with SSL on Ubuntu 24.04 (Complete Blueprint)
A complete guide to routing incoming HTTPS traffic to backend Node.js, Python, or Go microservices using an optimized Nginx reverse proxy with WebSocket support.