Enterprise-Grade, Open-Source Self-Hosted Cloud Platform
A complete self-hosted alternative to Vercel, Supabase, Railway, and Netlify.
Quickstart • Architecture • Features • Deployment Guide • Upgrades • Configuration
KH Cloud is a modern, full-stack cloud platform designed for developers, teams, and organizations who want the developer experience of Vercel, the database & storage capabilities of Supabase, and the infrastructure flexibility of Railway—hosted entirely on their own infrastructure with zero vendor lock-in.
Deploy full-stack applications with automatic GitOps CI/CD, managed databases (PostgreSQL, MySQL, Redis), S3-compatible object storage, sandboxed edge functions, and multi-tier DDoS protection under your own custom domains with zero source code modifications.
Deploy a complete, production-ready KH Cloud cluster on any Ubuntu/Debian VPS in under 3 minutes:
curl -fsSL https://raw.githubusercontent.com/khawarahemad/KH-cloude/main/install.sh | bashWhat the installer automates:
- Detects OS and installs Docker Engine & Docker Compose (if missing).
- Prompts for your root domain (
yourdomain.com) and Let's Encrypt email.- Generates cryptographically secure API keys and database credentials.
- Sets up persistent storage directories and permissions under
/var/lib/kh-cloud/.- Pulls pre-built multi-arch images from GitHub Container Registry (
ghcr.io).- Configures Traefik v3 edge routing with automated TLS/SSL certificate issuance.
To update an existing installation to the latest release with zero downtime and zero data loss:
curl -fsSL https://raw.githubusercontent.com/khawarahemad/KH-cloude/main/update.sh | bashAll persistent volumes (/var/lib/kh-cloud/), databases, storage files, and .env configuration remain completely intact across updates.
flowchart TD
Client["Client / Developer Browser"] -->|"HTTPS (Port 443)"| Traefik["Traefik v3 Edge Router & SSL Engine"]
subgraph CorePlatform["Core Platform Services"]
Traefik -->|"cloud.yourdomain.com"| Frontend["Next.js 15 Control Plane"]
Traefik -->|"api.yourdomain.com"| Backend["NestJS Cloud API Engine"]
Traefik -->|"storage.yourdomain.com"| StorageCtrl["Object Storage Gateway"]
Traefik -->|"auth.yourdomain.com"| Frontend
Traefik -->|"admin.yourdomain.com"| Frontend
Backend -->|"Internal TCP"| Redis[("Redis Rate Limiter & Cache")]
Backend -->|"Internal SQLite/Prisma"| DB[("System State Database")]
Backend -->|"Internal :9000"| MinIO[("MinIO S3 Storage Cluster")]
end
subgraph ManagedServices["Managed Cloud Workloads"]
Backend -->|"Docker Engine Socket"| Containers["Deployed User Web Apps"]
Backend -->|"Managed Containers"| ManagedDatabases["PostgreSQL / MySQL / Redis Instances"]
Backend -->|"In-Process VM Sandbox"| EdgeFunctions["Edge Functions Runtime"]
end
GitHub["GitHub Webhooks"] -->|"GitOps Push Events"| Backend
- Native GitHub App Integration: Selectively grant repository permissions without exposing account-wide tokens.
- Automated Docker BuildKit Pipeline: Push commits to your default branch to trigger automated container builds with isolated port allocation and zero-downtime rolling updates.
- Automatic SSL Provisioning: Automated Let's Encrypt TLS certificate generation and renewal for all apex domains and wildcard subdomains.
- Secure Environment Injection: Build-time
.envsynthesis for static client apps (Next.js, Vite, React) and runtime Docker--env-fileisolation with instant one-click redeploy triggers.
- One-Click Provisioning: Spin up isolated, containerized database instances instantly.
- Interactive 2D Table Editor: Spreadsheet-like data grid featuring sticky headers, column sorting, pagination, and inline CRUD record mutations.
- Embedded SQL Console: Execute raw SQL queries with formatted tabular result sets and execution timing.
- HTTP REST Query Engine: Securely perform database operations via RESTful endpoints authenticated by Team API keys (
kh_service_...orkh_anon_...). - SDK Connection Snippets: Ready-to-use boilerplate for Prisma ORM, SQLAlchemy, Node.js (
pg,mysql2,ioredis), and Python (requests).
- Universal File Support: Upload, organize, and stream PDFs, images (JPG, PNG, WebP, SVG), video (MP4, WebM), audio (MP3, WAV), documents, and ZIP archives.
- Integrated Previews: In-dashboard PDF reader, HTML5 media player, and lossless image zoom viewer.
- Deterministic URL Routing:
https://storage.yourdomain.com/:teamId/:bucketName/:objectKey - Standard S3 Protocol Compatibility: Works out-of-the-box with AWS SDK v3,
boto3, MinIO Client (mc), and standard HTTP clients.
- Zero-Latency Compute: Sub-millisecond cold starts powered by an isolated Node.js VM context.
- Pre-Bound Global Utilities: Sandbox environment includes
req,env,storage(S3 helpers),db(query runner), andfetch. - Flexible Invocations: Call edge functions publicly or restrict access via Team API keys.
- Isolated Team Namespaces: Multi-tenant architecture prevents naming collisions across teams.
- Role-Based Access Control (RBAC): Enforces
OWNER,ADMIN,DEVELOPER, andVIEWERpermission hierarchies. - Team Invitations: Manage team growth with secure email invites and role pre-assignment.
- Scoped API Tokens: Granular
anon(client-safe) andservice_role(elevated admin) tokens.
- Edge Layer Protection: Traefik network rate-limiting intercepts and throttles traffic before it reaches application processes.
- Application Layer Sliding-Window: Redis-backed token bucket algorithm in NestJS handles granular route rate-limiting.
- Intelligent Auto-Ban Engine: Automatically isolates abusive IP addresses with configurable TTL durations.
- AES-256-CBC PBKDF2 Encryption: Complete snapshots bundling SQLite DB, MinIO object storage files, SSL certificates (
acme.json), and platform configuration (.env). - Automated Remote Sync: Daily or on-demand push to a Private GitHub Backup Repository (via GitHub Releases API) or Remote S3 / Cloudflare R2 / AWS S3.
- 1-Command VPS Restore: Restore your entire cloud onto a brand-new VPS with zero data loss in under 3 minutes:
curl -fsSL https://raw.githubusercontent.com/khawarahemad/KH-cloude/main/restore.sh | bash
If your VPS ever crashes, is destroyed, or you wish to migrate to a new hosting provider, KH Cloud makes restoration effortless.
On your replacement Ubuntu/Debian server:
curl -fsSL https://raw.githubusercontent.com/khawarahemad/KH-cloude/main/restore.sh | bashThe wizard will:
- Automatically install Docker & Compose.
- Fetch your encrypted snapshot from your Private GitHub Repo, Cloudflare R2/S3, or a local file.
- Prompt for your
BACKUP_ENCRYPTION_KEYto decrypt the snapshot. - Restore all databases, MinIO files, SSL certificates, and
.env. - Pull pre-built GHCR images and launch the cluster!
To create an encrypted snapshot from the command line on your active server:
./backup.sh| Variable | Description | Default / Example |
|---|---|---|
BASE_DOMAIN |
Root domain for routing and SSL certificates | yourdomain.com |
ACME_EMAIL |
Email address registered with Let's Encrypt | admin@yourdomain.com |
ADMIN_API_KEY |
Secret bearer token for admin API endpoints | (Generate strong random string) |
BACKUP_ENCRYPTION_KEY |
Master AES-256 key for encrypting backup snapshots | (Generate strong 32-byte string) |
BACKUP_GITHUB_REPO |
Optional: Private GitHub backup target repo | your-username/my-khcloud-backups |
BACKUP_GITHUB_TOKEN |
Optional: GitHub Personal Access Token (PAT) | ghp_... |
BACKUP_S3_ENDPOINT |
Optional: Cloudflare R2 or AWS S3 endpoint URL | https://<id>.r2.cloudflarestorage.com |
BACKUP_S3_BUCKET |
Optional: Remote S3 backup bucket name | my-khcloud-backups |
MINIO_ROOT_USER |
S3 storage administrator username | khcloudroot |
MINIO_ROOT_PASSWORD |
S3 storage administrator password | (Generate strong random string) |
GOOGLE_CLIENT_ID |
Google OAuth Client ID for dashboard authentication | *.apps.googleusercontent.com |
GOOGLE_CLIENT_SECRET |
Google OAuth Client Secret | GOCSPX-... |
GITHUB_APP_ID |
GitHub App ID for GitOps deployments | 123456 |
GITHUB_APP_PRIVATE_KEY |
GitHub App PEM private key (newlines as \n) |
"-----BEGIN RSA...-----" |
GITHUB_APP_WEBHOOK_SECRET |
Secret for verifying GitHub webhook HMAC signatures | your_webhook_secret |
DDOS_GLOBAL_LIMIT |
Global requests per minute before rate-limiting | 200 |
DDOS_API_LIMIT |
API requests per minute before rate-limiting | 60 |
DDOS_BAN_THRESHOLD |
Violations before IP auto-ban is enforced | 5 |
DDOS_BAN_TTL_SECONDS |
Duration in seconds for temporary IP bans | 3600 |
Once deployed with your BASE_DOMAIN, the following endpoints are automatically routed with SSL certificates:
| Endpoint | Subdomain | Purpose |
|---|---|---|
| Control Plane | https://cloud.yourdomain.com |
Next.js 15 Web Dashboard & Project Workspace |
| Auth Hub | https://auth.yourdomain.com |
Dedicated OAuth Gateway & Session Router |
| Backend API | https://api.yourdomain.com |
NestJS REST API & GitHub Webhook Receiver |
| Object Storage | https://storage.yourdomain.com |
S3 Gateway & Media Streaming CDN |
| Admin Console | https://admin.yourdomain.com |
Platform Administration, Logs, & Security Metrics |
| User Deployments | https://<project-slug>.yourdomain.com |
Deployed user web applications |
- License: Released under the MIT License.
- Contributing: Contributions, issues, and feature requests are welcome. Please open an issue or pull request on GitHub.
- Repository: https://github.com/khawarahemad/KH-cloude