AgiCloud

Alongside the managed cloud version at agicloud.dev, AgiCloud is open source under the AGPL-3.0 license and can be self-hosted on your own Linux server or VPS.

This tutorial covers system requirements, installation and build commands (including the NODE_ENV=production gotcha), environment variables, and how to secure your instance with AUTH_TOKEN and an HTTPS reverse proxy.


Step 1: Check server requirements

Before installing, make sure your Linux server has:

  1. Node.js 22 or newer (enforced by "engines": { "node": ">=22" } in package.json) and npm.
  2. Git (also used to create git worktree separate copies for delegated threads and to install plugins from Git links).
  3. Standard build tools (python3, make, g++ — on Debian/Ubuntu, install build-essential), required by npm to compile the native node-pty module for persistent terminals.
  4. At least one coding agent CLI installed on the machine (claude, opencode, codex, cursor-agent, or agy; Cursor and agy can also be installed with one click directly from Settings → Agents).

Step 2: Clone, install dependencies, and build

  1. Clone the AgiCloud repository and enter the directory:
    git clone https://github.com/AgiCloudDev/AGICLOUD.git
    cd AGICLOUD
    
  2. Install dependencies and build the web interface (@agicloud/web):
    npm install
    npm run build          # compiles the web UI into apps/web/dist
    npm start              # starts the server on http://127.0.0.1:3095
    

Important note when NODE_ENV=production is set: when NODE_ENV=production is set in your environment, npm install and npm ci skip devDependencies (which include vite, typescript, and tsx), causing both npm run build and npm start to fail.

In production environments, always run:

npm ci --include=dev
npm run build

Step 3: Configure environment variables

AgiCloud is configured via environment variables (which you can pass on the command line or place in an environment file loaded by systemd or PM2):

Variable Default Purpose
PORT 3095 HTTP port the AgiCloud server listens on.
HOST 127.0.0.1 Bind address. Keep 127.0.0.1 when running behind a reverse proxy on the same machine.
AUTH_TOKEN (none on localhost) Secret Bearer token required to sign in to AgiCloud. Mandatory whenever HOST is not local (127.0.0.1, localhost, or ::1).
DATA_DIR data Directory where AgiCloud stores conversations (threads/), terminal sockets (terminals/), settings (settings.json), the Key Vault (vault.json, mode 600), Web Push keys and subscriptions (vapid.json, push.json), plugins (plugins/, plugin-data/), and the shared browser profile (browser-profile/).
PROJECT_ROOTS <DATA_DIR>/workspaces:$HOME:/opt:/var/www Colon-separated (:) list of allowed root directories where projects can be opened or created and files can be browsed. Any path outside these roots (including via symlinks) is rejected.
TRUST_PROXY (disabled) Set TRUST_PROXY=1 when AgiCloud runs behind a reverse proxy (Caddy, Nginx, etc.). This tells AgiCloud to read the client IP from X-Forwarded-For for brute-force protection (after 5 failed token attempts from the same IP, that IP is blocked for 15 minutes).
IDLE_MINUTES 30 Minutes of inactivity before a running agent is automatically put to sleep.
MAX_SESSIONS 6 Maximum number of agent processes kept alive simultaneously (beyond this limit, the least recently used idle agent is put to sleep).

Generate a strong AUTH_TOKEN

Generate a random secret token using OpenSSL:

openssl rand -base64 32

Golden security rule: never expose AgiCloud on 0.0.0.0 (or a public IP) without setting AUTH_TOKEN. Anyone who accesses your AgiCloud workspace can run coding agents and open shell terminals with the permissions of the Linux user running the server. In fact, AgiCloud (apps/server/src/config.ts) refuses to start and exits immediately if HOST is not local and AUTH_TOKEN is missing. On startup, AgiCloud also deletes AUTH_TOKEN from process.env so neither terminals nor agents can read it from the environment.


Step 4: Expose AgiCloud securely with an HTTPS Reverse Proxy

The recommended production setup for accessing AgiCloud from your phone or over the internet is:

  1. bind AgiCloud to localhost (HOST=127.0.0.1, PORT=3095) with AUTH_TOKEN and TRUST_PROXY=1;
  2. put an HTTPS reverse proxy (such as Caddy or Nginx) in front of it.

Why HTTPS is essential: besides encrypting your AUTH_TOKEN and project files in transit, modern browsers (Safari on iOS, Chrome on Android and desktop) only enable Service Workers, PWA app installation, and Web Push notifications over secure https:// origins (or localhost).

Option 1: Caddy (recommended)

Caddy automatically provisions and renews Let's Encrypt TLS certificates and forwards both WebSockets (terminals and Shared Browser) and Server-Sent Events (chat streams) out of the box.

In /etc/caddy/Caddyfile:

agicloud.yourdomain.com {
    reverse_proxy 127.0.0.1:3095
}

Then reload Caddy with sudo systemctl reload caddy.

Option 2: Nginx

If you use Nginx, make sure to pass the Upgrade and Connection headers for WebSockets (used by /api/terminals/ and /api/browser/ws) and disable proxy buffering (proxy_buffering off) so SSE chat events stream immediately:

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

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

    client_max_body_size 110M;

    location / {
        proxy_pass http://127.0.0.1:3095;
        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;

        # WebSockets (Terminal and Shared Browser)
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";

        # Real-time SSE streaming for Chat
        proxy_buffering off;
        proxy_read_timeout 3600s;
    }
}

Step 5: Start AgiCloud with your configuration

Here is a complete command to launch AgiCloud behind a reverse proxy:

HOST=127.0.0.1 \
PORT=3095 \
TRUST_PROXY=1 \
AUTH_TOKEN="your-secret-token-generated-with-openssl" \
DATA_DIR="/home/user/agicloud-data" \
PROJECT_ROOTS="/home/user/projects:/var/www" \
npm start

When you open https://agicloud.yourdomain.com on your phone or computer, paste your Access token and press Sign in.


Next step

Want to extend AgiCloud by adding a custom section to the sidebar menu, new server API routes, or new MCP tools for all your agents? In the final tutorial, let's see how to build a complete AgiCloud plugin:

👉 12 — Writing an AgiCloud plugin