Skip to content

Hosting

Roi Horowitz edited this page Dec 2, 2026 · 2 revisions

Hosting

The bot is a small Node.js app (or Docker container) that has to:

  • stay on. Players roll while you're away, and Discord needs a constant connection.
  • keep its data. Everything lives in DATA_DIR/store.json, so give it a persistent disk.
  • be reachable from the GM's browser. The module talks to it directly, and if Foundry is served over https (The Forge, most hosts, any public setup), the bot needs an https address too. Browsers only allow plain http:// for a bot on http://localhost, on the GM's own machine.

Pick a setup

Your Foundry Recommended bot hosting
The Forge or another managed host Home PC / Pi + Cloudflare Tunnel (free), or a VPS / Railway / Fly.io
Self-hosted on a VPS The same VPS, behind your reverse proxy
Self-hosted at home The same machine, with a Cloudflare Tunnel or your existing reverse proxy
Local only (http://localhost:30000, everyone on your PC) The same PC, http://localhost:8787; no https needed

Avoid hosts that sleep when idle, such as free "web service" tiers that spin down after a few minutes. The bot would drop off Discord and commands would fail.

Whatever you choose, these two settings must match:

  • FOUNDRY_ORIGIN (bot .env): exactly the address in the GM's address bar when the world is open, e.g. https://yourgame.forge-vtt.com. List every address people use, comma-separated (e.g. a custom domain too).
  • Bot URL (Foundry setup window): the bot's public address, e.g. https://roller.example.com.

Registering commands only needs the three Discord variables, so you can run npm run register once from any PC with a copy of the bot and a .env. You don't have to run it on the server.


The Forge

  1. Install the module from the manifest URL (Installation) and enable it in your world.
  2. Host the bot with any option below. The Forge only runs Foundry, not your own programs, so the bot can't live there.
  3. Set FOUNDRY_ORIGIN to your game's address as it appears in the browser while the world is open, e.g. https://yourgame.forge-vtt.com.
  4. In Set up Discord, enter the bot's https address as the Bot URL.

The Data-folder warning in Security doesn't apply here, because the bot never runs on the Forge.


Home PC or Raspberry Pi + Cloudflare Tunnel

Free, no port forwarding, real https. It needs a domain on Cloudflare (a cheap one works), and the machine must stay on.

  1. Run the bot on the machine (Bot Setup) and confirm http://localhost:8787/api/health works there.
  2. In the Cloudflare dashboard: Zero Trust → Networks → Tunnels → Create a tunnel (Cloudflared). Follow the install command it shows for your OS. That installs cloudflared as a service.
  3. Add a public hostname, e.g. roller.example.com, with service HTTP → localhost:8787.
  4. Open https://roller.example.com/api/health. It should return {"ok":true,…}.
  5. Use https://roller.example.com as the Bot URL.

Prefer the CLI? Use cloudflared tunnel login, then cloudflared tunnel create squire and cloudflared tunnel route dns squire roller.example.com, with an ingress rule to http://localhost:8787.

Quick tunnels (*.trycloudflare.com) get a new address every restart, so you'd have to update the Bot URL each time. Use a named tunnel.


VPS with Docker + Caddy

Any small Linux VPS works. Point a DNS A record (e.g. roller.example.com) at the server, then copy the bot/ folder there with your .env, and add:

docker-compose.yml

services:
  bot:
    build: .
    env_file: .env
    volumes:
      - bot-data:/data
    restart: unless-stopped
  caddy:
    image: caddy:2
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile
      - caddy-data:/data
    restart: unless-stopped
volumes:
  bot-data:
  caddy-data:

Caddyfile

roller.example.com {
  reverse_proxy bot:8787
}
docker compose run --rm bot node src/register.js   # once
docker compose up -d

Caddy gets and renews the https certificate automatically. The Bot URL is https://roller.example.com.

Without Docker: install Node 20+ and run the bot with pm2 or a systemd service, and put Caddy or nginx in front of localhost:8787 the same way.


Railway

  1. Push the repository (or your fork) to GitHub and create a Railway project from it.
  2. In the service settings, set the root directory to bot. Railway builds the included Dockerfile.
  3. Add the variables from .env.example (DISCORD_TOKEN, FOUNDRY_TOKEN, FOUNDRY_ORIGIN, …).
  4. Add a volume mounted at /data.
  5. Under networking, generate a public domain for port 8787. That https address is your Bot URL.

Fly.io

From the bot/ folder:

fly launch --no-deploy            # uses the Dockerfile; pick a name and region
fly volumes create data --size 1
fly secrets set DISCORD_TOKEN=… DISCORD_CLIENT_ID=… DISCORD_GUILD_ID=… FOUNDRY_TOKEN=… FOUNDRY_ORIGIN=https://yourgame.forge-vtt.com GM_DISCORD_IDS=…

In fly.toml, mount the volume and keep one machine running, because Fly stops idle machines by default, which would drop the bot from Discord:

[mounts]
  source = "data"
  destination = "/data"

[http_service]
  internal_port = 8787
  force_https = true
  auto_stop_machines = "off"
  auto_start_machines = true
  min_machines_running = 1

Then fly deploy. The Bot URL is https://<app-name>.fly.dev.


Same server as a self-hosted Foundry

Run the bot on the Foundry server, outside Foundry's Data folder (Security), and give it its own subdomain on your existing reverse proxy:

Caddy

bot.example.com {
  reverse_proxy localhost:8787
}

nginx

server {
  server_name bot.example.com;
  listen 443 ssl;
  # ssl_certificate … (e.g. from certbot)
  location / {
    proxy_pass http://127.0.0.1:8787;
    proxy_set_header Host $host;
  }
}

The Bot URL is https://bot.example.com, and FOUNDRY_ORIGIN is your Foundry address.


After deploying

  1. Open <Bot URL>/api/health in the GM's browser. It should show {"ok":true,…}.
  2. In Foundry, Set up Discord → Save (or Sync now).
  3. Check /api/health again: your world should be listed with snapshotAgeDays: 0.

If the sync fails, see Troubleshooting.

Clone this wiki locally