Free sample · no email · 1,700 of 11,788 words
Ship It to Your Own Server
The opening of the playbook as your AI agent reads it. The full volume adds the step-by-step playbook, the prompts, the checklist and the sources.
1. The problem
Why this matters
AI tools have made it remarkably easy to build a working web app. Getting it online is where many people stall. The choices look like this:
- Managed platforms (Vercel, Netlify, Render, Railway, Fly.io and others) are excellent and often the right choice. But pricing can grow with usage or team size, some workloads do not fit them well (long-running jobs, background workers, self-hosted open-source tools with their own databases), and you live within each platform’s limits.
- A virtual private server (VPS) is a rented Linux machine with a fixed monthly price. You can run almost anything on it: your app, its database, an n8n automation server, a WordPress site and a status page, side by side. The trade-off is that you are responsible for it: security, updates, backups.
A VPS used to mean learning a lot of Linux administration. Two things changed that. First, Docker and Docker Compose turned “install this app” into “run this file”. Second, modern reverse proxies like Caddy obtain and renew HTTPS certificates automatically. With an AI agent typing the commands, a careful non-specialist can now run a server well, as long as they follow a method and know which actions need their approval.
What usually goes wrong
- Logging in as root with a password, forever. Internet-facing SSH servers receive automated password-guessing attempts constantly. A weak root password is an invitation.
- A firewall that does not do what you think. Ports published by Docker bypass rules set with UFW on Ubuntu, a behavior Docker documents. People “close” a database port in UFW while Docker keeps it open to the world.
- Secrets in the repository. A
.envfile with the database password committed to GitHub. - No backups, or backups never tested. The first restore attempt happens during the emergency.
- Hand-edited servers. Changes made by hand at 2 a.m. that nobody wrote down, so the server cannot be rebuilt.
- Updating by hope.
docker compose pull && docker compose up -don a Friday evening, with no way back to the previous version. - The agent with the keys. An AI agent given root access and told “make it work”, which then deletes a volume to fix a database error.
What good looks like
At the end of this playbook you will have:
- A server you log into with an SSH key as a normal user, with root and password logins disabled, a firewall allowing only SSH, HTTP and HTTPS, automatic security updates, and fail2ban watching SSH.
- Your domain pointing to the server, with HTTPS certificates issued and renewed automatically.
- Each app defined in a Docker Compose file kept in a repository (without secrets), so the server can be rebuilt from scratch.
- Secrets in a protected file on the server and in your password manager.
- Automatic, off-server backups, and a restore you have actually performed.
- An external uptime check that alerts you, and a known way to read logs.
- A written update and rollback procedure.
- A clear agreement with your AI agent about what it may run alone and what it must show you first.
2. Before you start
Inputs you need
- The app. Either your own code (a folder or Git repository) or the name of an open-source app you want to run.
- A domain name you control, and login access to wherever its DNS is managed (your registrar, or a DNS service such as Cloudflare).
- A payment method for a VPS provider.
- A computer with a terminal. macOS and Linux have one built in; on Windows, use Windows Terminal with the built-in OpenSSH client or WSL.
- An AI agent that can run commands, such as Claude Code, in a terminal on your computer. It will connect to the server over SSH using your key.
- A password manager (1Password, Bitwarden, or similar) for server credentials and app secrets.
- An email address for certificate and alert notifications.
- Somewhere to send backups: an S3-compatible object storage bucket (most providers listed here sell one; Backblaze B2 and Cloudflare R2 are other options) or another server.
Sizing questions
Your agent will ask these; know the answers roughly.
- What runs on the server: one app, or several (app + database + n8n + WordPress)?
- Does the app need a database? Which one?
- Expected traffic: a few hundred visitors a day, or thousands an hour?
- Will users upload files? How much storage over a year?
- Where are your users? Choose a data center region near them, and consider data-residency rules for your customers.
Intake checklist
- App source location (repo URL or folder) or open-source app name
- Runtime: Node.js/Next.js, Python, static, PHP, other
- Database: none, PostgreSQL, MySQL/MariaDB, SQLite, Redis
- Domain and subdomain to use (for example
app.example.com) - DNS provider and login confirmed
- Preferred VPS provider and region
- Contact email for certificates and alerts
- Backup destination chosen
- Password manager vault created for this project
- Your rules for the agent agreed (section 4.13)
Done when: every item above has an answer written in deploy/intake.md in your project.
3. The method
Ten steps. Each depends on the one before it; do not skip ahead to deploying before hardening.
Step 1: Choose and create the server
- What to do: Pick a provider and plan, choose Ubuntu 24.04 LTS, add your SSH public key during creation, and enable the provider’s backup or snapshot feature if offered.
- Why: Adding the key at creation means the server never needs a password login. Provider snapshots give you a full-machine undo button.
- Done when: you can run
ssh root@SERVER_IP(or the provider’s default user) with your key, without typing a server password, and you have noted the server’s IPv4 (and IPv6, if any) address.
Step 2: Harden the first login
- What to do: Update packages, create a non-root user with sudo, disable root and password SSH login, enable the firewall for SSH/HTTP/HTTPS only, turn on automatic security updates, install fail2ban.
- Why: These six changes remove the most common ways small servers are compromised.
- Done when: you can log in as your new user with your key;
ssh root@SERVER_IPis refused; a password login attempt is refused;sudo ufw statusshows only 22, 80 and 443 allowed;systemctl status fail2banis active; unattended-upgrades is enabled.
Step 3: Point the domain at the server
- What to do: Create an A record (and AAAA for IPv6) for your domain or subdomain pointing to the server’s IP.
- Why: Automatic HTTPS needs the domain to resolve to the server before a certificate can be issued.
- Done when:
dig +short app.example.comreturns your server’s IP from your computer and from a public DNS checker.
Step 4: Install Docker and Docker Compose
- What to do: Install Docker Engine and the Compose plugin from Docker’s official repository, and create a shared Docker network for the proxy.
- Why: Containers make every app reproducible from a file, and isolate apps from each other.
- Done when:
docker run --rm hello-worldsucceeds anddocker compose versionprints a version.
Step 5: Put a reverse proxy with automatic HTTPS in front
- What to do: Run Caddy in a container on ports 80 and 443, with a Caddyfile that maps each domain to an app container. (Alternative: Nginx plus Certbot.)
- Why: One proxy terminates HTTPS for all apps, obtains and renews certificates, and lets apps stay off the public internet.
- Done when:
https://app.example.comshows a valid certificate in the browser andhttp://redirects tohttps://.
Step 6: Deploy the app
- What to do: Write a Dockerfile (for your own code) or use the official image (for open-source apps), write a Compose file, connect it to the proxy network, and start it.
- Why: The Compose file is the single source of truth for how the app runs.
- Done when: the app works at its HTTPS URL, survives
sudo reboot(comes back up by itself), and no app or database port is reachable from outside except through the proxy.
Step 7: Handle secrets properly
- What to do: Keep secrets in a
.envfile on the server with restrictive permissions and in your password manager; commit only a.env.examplewith placeholder names. - Why: Secrets in Git are the most common avoidable leak.
- Done when:
git log -pcontains no real secret,.envis in.gitignore, the server’s.envis mode 600, and every secret also exists in your password manager.
Step 8: Back up and test a restore
- What to do: Schedule database dumps and volume backups to off-server storage, keep provider snapshots on, and restore a backup to a separate place to prove it works.
- Why: A backup you have not restored is a hope, not a backup.
- Done when: backups run automatically every day, the newest backup is visible in off-server storage, and you have completed one restore into a test environment and recorded the steps.
Step 9: Monitor and read logs
- What to do: Add an external uptime check with alerts, cap Docker log sizes, and learn the three commands for reading logs.
- Why: You should hear about an outage from an alert, not a customer.
- Done when: stopping the app container triggers an alert to you within the check interval, and starting it again sends a recovery notice.
Step 10: Update and roll back safely
- What to do: Pin image versions, update with a written procedure (backup, pull, up, verify), and keep the previous version ready to restore.
- Why: Most outages after launch are caused by changes. A rollback plan turns a bad update into a five-minute inconvenience.
- Done when: you have performed one update and one deliberate rollback using the written procedure, and both are recorded in
deploy/runbook.md.
Keep going: the full playbook
- Playbook steps
- Prompts
- Checklist
- Measuring results
- Common mistakes
Book + Claude skill + MCP access. Black Friday 2026 price. Back to the book page
Or start free
4 complete playbooks, the 7-day Claude Code course and a key your AI can use right now. No card.
Free. We email you about new lessons and volumes now and then. Unsubscribe any time.
Your free key
Install (Claude Code, Codex, Gemini CLI)
Other apps: add the MCP server https://playbookmcp.com/mcp with header Authorization: Bearer + your key. Keep this key; it is shown once.