NewCode CLOUD — 20% off your first month on all cloud VPSClaim

How to Deploy Strapi Headless CMS on Hong Kong VPS (2026)

· 5 min read

Strapi is the leading open-source headless CMS — it gives content editors a friendly admin panel while developers consume content via REST or GraphQL APIs. Self-hosting on a Hong Kong VPS eliminates Strapi Cloud’s per-seat pricing, keeps content data on your own infrastructure, and delivers API responses to Asian frontend applications at CN2 GIA speeds rather than US-hosted latency.


When to Choose Self-Hosted Strapi

  • Content teams larger than 3–5 editors where Strapi Cloud pricing scales per user
  • Applications where content must remain on controlled infrastructure (compliance, data residency)
  • High-traffic frontends where Strapi Cloud’s API rate limits would apply
  • Teams that need custom plugins or deep Strapi configuration control

VPS Requirements

Team Size RAM vCPU Notes
Small (1–5 editors) 2 GB 2 Comfortable for most content workloads
Medium (5–20 editors) 4 GB 4 Add Redis for session caching
Large + high API traffic 8 GB 8 Multiple Strapi processes + PostgreSQL

Step 1: Install Node.js and Dependencies

apt update && apt upgrade -y
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
apt install -y nodejs nginx certbot python3-certbot-nginx ufw

npm install -g pm2

# Install PostgreSQL
apt install -y postgresql postgresql-contrib
sudo -u postgres psql << 'SQL'
CREATE DATABASE strapi_prod;
CREATE USER strapi WITH PASSWORD 'StrongStrapiPass!';
GRANT ALL PRIVILEGES ON DATABASE strapi_prod TO strapi;
ALTER DATABASE strapi_prod OWNER TO strapi;
SQL

Step 2: Create Strapi Project

<code">useradd -m -s /bin/bash strapi
su - strapi

npx create-strapi-app@latest myapp \
  --dbclient=postgres \
  --dbhost=127.0.0.1 \
  --dbport=5432 \
  --dbname=strapi_prod \
  --dbusername=strapi \
  --dbpassword=StrongStrapiPass! \
  --no-run

Production Environment File

<code">cat > /home/strapi/myapp/.env << 'EOF'
HOST=0.0.0.0
PORT=1337
APP_KEYS=$(openssl rand -base64 32),$(openssl rand -base64 32)
API_TOKEN_SALT=$(openssl rand -base64 32)
ADMIN_JWT_SECRET=$(openssl rand -base64 32)
TRANSFER_TOKEN_SALT=$(openssl rand -base64 32)
JWT_SECRET=$(openssl rand -base64 32)

DATABASE_CLIENT=postgres
DATABASE_HOST=127.0.0.1
DATABASE_PORT=5432
DATABASE_NAME=strapi_prod
DATABASE_USERNAME=strapi
DATABASE_PASSWORD=StrongStrapiPass!

NODE_ENV=production
EOF
chmod 600 /home/strapi/myapp/.env

Build Admin Panel

<code">cd /home/strapi/myapp
NODE_ENV=production npm run build

Step 3: PM2 Process Management

<code">cat > /home/strapi/myapp/ecosystem.config.js << 'EOF'
module.exports = {
  apps: [{
    name: 'strapi',
    cwd: '/home/strapi/myapp',
    script: 'npm',
    args: 'start',
    env: {
      NODE_ENV: 'production',
      PORT: 1337
    },
    instances: 1,
    max_memory_restart: '1G',
    error_file: '/home/strapi/logs/error.log',
    out_file: '/home/strapi/logs/out.log',
    merge_logs: true,
    time: true
  }]
};
EOF

mkdir -p /home/strapi/logs
pm2 start /home/strapi/myapp/ecosystem.config.js
pm2 save && pm2 startup systemd

Step 4: Nginx Reverse Proxy

<code">exit  # Back to root

cat > /etc/nginx/sites-available/strapi << 'EOF'
upstream strapi {
    server 127.0.0.1:1337;
    keepalive 16;
}

server {
    listen 443 ssl http2;
    server_name cms.yourdomain.com;

    ssl_certificate /etc/letsencrypt/live/cms.yourdomain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/cms.yourdomain.com/privkey.pem;

    client_max_body_size 100m;

    # Admin panel — restrict to known IPs in production
    location /admin {
        # allow YOUR_OFFICE_IP;
        # deny all;
        proxy_pass http://strapi;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_set_header Host $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;
    }

    # Public API — rate limited
    location /api/ {
        limit_req zone=strapi_api burst=50 nodelay;
        proxy_pass http://strapi;
        proxy_http_version 1.1;
        proxy_set_header Host $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;
    }

    # Uploads
    location /uploads/ {
        proxy_pass http://strapi;
        expires 30d;
        add_header Cache-Control "public, immutable";
    }
}
EOF

# Add rate limit zone to nginx.conf http block:
# limit_req_zone $binary_remote_addr zone=strapi_api:10m rate=30r/s;

ln -s /etc/nginx/sites-available/strapi /etc/nginx/sites-enabled/
certbot --nginx -d cms.yourdomain.com
nginx -t && systemctl reload nginx

Step 5: Configure Content Types

Access the admin panel at https://cms.yourdomain.com/admin and create your first admin account. From the Content-Type Builder:

  1. Create a Collection Type for repeating content (Blog Posts, Products, Press Releases)
  2. Add fields: Title (Text), Slug (UID), Body (Rich Text), Cover Image (Media), Published Date (Date)
  3. Save and Strapi auto-generates REST and GraphQL API endpoints

API Access Control

In Settings → API Tokens → Create new API Token: generate read-only tokens for your frontend applications. Full-access tokens for CI/CD pipelines that need to create or update content.


Step 6: Consume the Strapi API from Your Frontend

<code"># REST API — list published blog posts
curl https://cms.yourdomain.com/api/posts?populate=coverImage \
  -H "Authorization: Bearer YOUR_API_TOKEN"

# Filter and sort
curl "https://cms.yourdomain.com/api/posts?sort=publishedAt:desc&pagination[page]=1&pagination[pageSize]=10" \
  -H "Authorization: Bearer YOUR_API_TOKEN"
<code"># JavaScript (Next.js example)
const response = await fetch(
  `${process.env.NEXT_PUBLIC_STRAPI_URL}/api/posts?populate=coverImage`,
  { headers: { Authorization: `Bearer ${process.env.STRAPI_API_TOKEN}` } }
);
const { data } = await response.json();

// data is an array of post objects with all fields including the populated image

Step 7: Media Storage — Cloudflare R2

By default, Strapi stores uploads on the VPS filesystem. For production, configure Cloudflare R2 (zero egress fees) as the upload provider:

<code">cd /home/strapi/myapp
npm install @strapi/provider-upload-aws-s3

cat > config/plugins.js << 'EOF' module.exports = ({ env }) => ({
  upload: {
    config: {
      provider: 'aws-s3',
      providerOptions: {
        credentials: {
          accessKeyId: env('R2_ACCESS_KEY_ID'),
          secretAccessKey: env('R2_SECRET_ACCESS_KEY'),
        },
        region: 'auto',
        endpoint: `https://${env('R2_ACCOUNT_ID')}.r2.cloudflarestorage.com`,
        params: {
          Bucket: env('R2_BUCKET'),
        },
      },
      actionOptions: {
        upload: {},
        uploadStream: {},
        delete: {},
      },
    },
  },
});
EOF

Add R2 credentials to your .env file and rebuild: NODE_ENV=production npm run build. Media uploads now go directly to R2 and are served via Cloudflare’s CDN — no VPS disk space consumed, no egress charges.


Step 8: Automated Backup

<code">cat > /opt/strapi-backup.sh << 'EOF' #!/bin/bash DATE=$(date +%Y%m%d_%H%M%S) BACKUP_DIR="/opt/backups/strapi" mkdir -p $BACKUP_DIR # Database sudo -u postgres pg_dump strapi_prod | \ gzip > $BACKUP_DIR/strapi_db_$DATE.sql.gz

# Uploads (if stored locally)
tar czf $BACKUP_DIR/strapi_uploads_$DATE.tar.gz \
  /home/strapi/myapp/public/uploads/ 2>/dev/null || true

# Keep 7 days
find $BACKUP_DIR -mtime +7 -delete
echo "Strapi backup: $DATE"
EOF
chmod +x /opt/strapi-backup.sh
crontab -l | { cat; echo "0 2 * * * /opt/strapi-backup.sh"; } | crontab -

Updating Strapi

<code">su - strapi
cd /home/strapi/myapp

# Update Strapi packages
npm install @strapi/strapi@latest @strapi/plugin-users-permissions@latest

# Rebuild admin panel
NODE_ENV=production npm run build

# Restart via PM2
pm2 restart strapi

Conclusion

Self-hosted Strapi on a Hong Kong VPS gives content teams a powerful, unlimited-editor headless CMS that delivers its REST and GraphQL APIs to Asian frontends via CN2 GIA routing at 30–60ms. Cloudflare R2 for media storage eliminates storage costs and serves images via global CDN, while PM2 and systemd ensure Strapi restarts automatically on crash or reboot. The total monthly cost — one VPS plan — replaces Strapi Cloud’s per-seat pricing that scales with team size.

Launch your headless CMS: Browse Server.HK Hong Kong VPS plans — a 4 GB plan handles Strapi, PostgreSQL, and moderate API traffic for most content teams.

Related articles

More in VPS & ServersServer setup guides