> For the complete documentation index, see [llms.txt](https://www.openclawbook.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.openclawbook.xyz/en/ch08-regional-platforms-and-deployment/8.2-cloud-deployment-in-practice.md). Agents can also search and read this documentation through its [MCP server](https://www.openclawbook.xyz/~gitbook/mcp).

# 8.2 Cloud Deployment in Practice

> **Generated by**: Claude Opus 5 (claude-opus-5\[1m]) **Token usage**: Input \~184,000 tokens, Output \~9,000 tokens (this section) **Source baseline**: `v2026.3.9` (`v2026.3.8-170-g665f67726`)

***

Running OpenClaw on a VPS rather than your laptop makes it always-on. This section covers doing that safely — with notes specific to Chinese cloud providers, though most of it generalizes.

## 8.2.1 Choosing and Preparing a Server

### Sizing

| Workload                     | Suggested                                         |
| ---------------------------- | ------------------------------------------------- |
| Personal use, a few channels | 2 vCPU / 2 GB RAM                                 |
| Plus browser automation      | 2 vCPU / 4 GB RAM (Chrome is the memory consumer) |
| Plus sandboxing              | 4 vCPU / 8 GB RAM (Docker containers)             |

**Disk matters more than you'd expect** if you enable memory indexing — the SQLite index plus session transcripts grow steadily. 40 GB is comfortable.

### Provider notes

| Provider              | Notes                                                                                  |
| --------------------- | -------------------------------------------------------------------------------------- |
| **Alibaba Cloud ECS** | Widest region coverage; Hong Kong and Singapore regions avoid ICP filing requirements  |
| **Tencent Cloud CVM** | Comparable; often cheaper on promotional pricing                                       |
| **Overseas regions**  | If your models are Western APIs, an overseas region avoids the network issues entirely |

> **A practical point**: if you're using Anthropic or OpenAI as your primary model, deploying to a mainland region means every model call crosses a difficult network path. Either deploy overseas, or use regional model providers (§7.3) — the latter is often simpler and cheaper.

### Initial setup

```bash
# Node.js 22+
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt install -y nodejs

# OpenClaw
npm install -g openclaw

# Verify
openclaw --version
```

## 8.2.2 Security Groups, Domains, and Reverse Proxy

### The most important rule

**Do not open port 18789 in your security group.**

The gateway binds to loopback by default, and that default is correct. Opening it to the internet exposes a **full operator-access surface** — past authentication, the caller is a trusted operator of your agent (§44.4).

### Three ways to reach it remotely, from safest

**1. SSH tunnel — nothing exposed at all**

```bash
ssh -N -L 18789:127.0.0.1:18789 user@your-server
```

Then point your local client at `localhost:18789`. **Nothing is publicly reachable.** For personal use this is genuinely sufficient.

**2. Tailscale — reachable within your tailnet**

```bash
curl -fsSL https://tailscale.com/install.sh | sh
sudo tailscale up
```

```json5
{
  gateway: {
    bind: "tailnet",
    tailscale: { mode: "serve" },
  },
}
```

`serve` mode keeps the gateway on loopback and lets Tailscale terminate TLS. **Your phone and laptop reach it; the internet doesn't.**

**3. Reverse proxy with a domain — only when you need a public webhook**

Necessary if an external service must POST to you (WeCom callbacks, GitHub webhooks). Caddy handles TLS automatically:

```
gateway.example.com {
    reverse_proxy 127.0.0.1:18789
}
```

```json5
{
  gateway: {
    bind: "loopback",             // keep it on loopback; the proxy reaches it locally
    auth: { mode: "password" },   // required for any public exposure
    trustedProxies: ["127.0.0.1"],
  },
}
```

**If you go this route, run `openclaw security audit`** — it specifically checks binding-and-auth combinations, incomplete trusted-proxy configuration, and short tokens (§32.6.4).

### WebSocket support in the proxy

The gateway's primary protocol is WebSocket, so the proxy must forward upgrade headers. Caddy does this automatically; Nginx needs it spelled out:

```nginx
location / {
    proxy_pass http://127.0.0.1:18789;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_read_timeout 86400;     # long-lived connections
}
```

**The `proxy_read_timeout` line matters** — the default 60 seconds will drop your agent connections mid-conversation.

## 8.2.3 ICP Filing and Cost

### ICP filing

Only relevant if you're serving a **public domain from a mainland Chinese server**:

| Situation                           | Filing needed?                      |
| ----------------------------------- | ----------------------------------- |
| SSH tunnel only                     | **No** — nothing is served publicly |
| Tailscale                           | **No** — not public                 |
| Public domain, mainland server      | **Yes**                             |
| Public domain, Hong Kong / overseas | **No**                              |

Given that the first two options are also the safer ones, most personal deployments never encounter this.

### Rough monthly cost

| Item               | Estimate                                        |
| ------------------ | ----------------------------------------------- |
| VPS (2C/4G)        | $10–25                                          |
| Domain (if needed) | \~$1                                            |
| Model API          | **Highly variable — usually the dominant cost** |

**The server is rarely what costs you.** Model usage is, which is why §7.2.3's cost optimization matters more than server sizing — particularly assigning cheap models to scheduled jobs and heartbeats, which run constantly.

### Keeping it running

```bash
openclaw gateway install        # install as a systemd service
openclaw gateway status
```

The service installer handles the platform quirks described in Appendix F.2 — including `loginctl enable-linger`, without which your service dies when you log out of SSH.

> **That's a real trap**: install the service, log out, and come back to find it stopped. `enable-linger` is what prevents it, and OpenClaw's installer sets it — but if you wrote your own unit file, check it.

***

## Section Summary

1. **Do not open port 18789** — the gateway binds to loopback by default and that default is correct; exposing it publishes a **full operator-access surface**.
2. **Three remote-access options, safest first**: SSH tunnel (nothing exposed, sufficient for personal use), Tailscale `serve` (tailnet only), reverse proxy with a domain (**only when an external service must POST to you**).
3. **Run `openclaw security audit` if you expose anything** — it checks binding-and-auth combinations, trusted-proxy configuration, and token strength specifically.
4. **A reverse proxy must forward WebSocket upgrades and raise `proxy_read_timeout`** — the default 60 seconds drops agent connections mid-conversation.
5. **ICP filing only applies to a public domain on a mainland server** — the two safer access options avoid it entirely.
6. **The server is rarely the cost; model usage is** — which makes cheap models for scheduled jobs and heartbeats the higher-leverage optimization.
7. **`loginctl enable-linger` is what keeps the service alive after you log out of SSH** — OpenClaw's installer sets it; a hand-written unit file might not.
