How to Install Foundry VTT on a VPS

Running a tabletop RPG campaign once meant dragging miniatures, a battle map, and a 20-pound rulebook to somebody’s dining room table. Today you can run an entire campaign from a browser tab. Foundry Virtual Tabletop is one of the most powerful ways to do exactly that — a self-hosted, endlessly extensible platform that puts dynamic lighting, interactive maps, and real-time dice rolling in the hands of any game master with a server.

That “self-hosted” part carries real weight. Foundry VTT operates on a one-time license, not a subscription. You pay once and the software is yours. Your worlds, your assets, and your player data live on hardware you control. No vendor lock-in. No monthly bill creeping upward.

This guide walks you through a complete Foundry VTT installation on a VPS running Ubuntu 22.04 or 24.04 LTS. By the end, you’ll have a production-ready instance with Node.js, a systemd-managed service, Nginx as a reverse proxy, and a Let’s Encrypt SSL certificate securing everything.

What Is Foundry Virtual Tabletop?

Foundry Virtual Tabletop is a Node.js web application built for running tabletop roleplaying games online. Players connect through a standard browser — no plugins, no downloads, just a URL. The game master controls everything: maps, tokens, lighting effects, audio tracks, initiative order, and more.

The module ecosystem is what really sets Foundry apart. Thousands of community-built add-ons expand on the platform’s already impressive core. You can automate D&D 5e combat rules, add cinematic weather to your maps, or pipe voice chat directly into the game interface. Support spans almost every TTRPG system imaginable — from Pathfinder 2e and Call of Cthulhu to niche indie systems with devoted but small player bases.

Hosting Foundry on a VPS solves the biggest pain point of desktop-based hosting: reliability. Your players can connect any time without someone’s gaming PC sitting powered on and idle. Sessions start on schedule, game worlds persist between them, and a stable server address means your group always knows where to find the game.

Prerequisites

Before diving in, make sure you have the following ready:

  • A Foundry VTT license — a one-time purchase at foundryvtt.com
  • A VPS running Ubuntu 22.04 or 24.04 LTS
  • SSH access as a non-root sudo user
  • A domain name with an A record already pointing to your server’s IP address

Here are the server specs you’ll want to hit:

Spec Minimum Recommended
CPU 1 vCPU 2 vCPUs
RAM 1 GB 2 GB
Storage 20 GB SSD 40 GB SSD
OS Ubuntu 22.04 LTS Ubuntu 22.04 / 24.04 LTS

Campaigns with high-resolution maps, ambient audio tracks, and a table full of players can push RAM usage well past 1 GB. Starting with 2 GB saves you a future headache.

How to Install Foundry VTT on a VPS

Step 1: Update the System

Log in to your server via SSH and bring all packages up to date before installing anything new.

sudo apt update && sudo apt upgrade -y

Step 2: Install Node.js 20 LTS

Foundry VTT runs on Node.js. Ubuntu’s default package repository ships an older version so pull Node.js 20 LTS directly from NodeSource instead.

curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs

Verify the installation:

node --version
npm --version

The first command should return a version starting with v20. If both commands return version numbers without errors, you’re good to go.

Step 3: Set Up a Dedicated User and Directory Structure

Running Foundry VTT as root is a security risk. Create a dedicated system user called foundry with its own home directory.

sudo useradd -r -m -d /home/foundry -s /bin/bash foundry

Now create separate directories for the application files and your persistent world data:

sudo mkdir -p /home/foundry/foundryvtt
sudo mkdir -p /home/foundry/foundrydata
sudo chown -R foundry:foundry /home/foundry

Keeping the application files in foundryvtt and your game data in foundrydata is intentional. When you update Foundry to a newer version, you replace the application files without touching your worlds, characters, or assets. Clean updates, zero drama.

Step 4: Download and Extract Foundry VTT

Foundry VTT distributes its software through time-limited download URLs tied to your account. Each URL expires after five minutes so generate it right before you download.

Here’s how to get the URL:

  1. Log in at foundryvtt.com.
  2. Navigate to Purchased Licenses.
  3. Click the chain-link icon next to the Node.js build of your license.
  4. Copy the full timed URL from the dialog that appears.

Back on your server, install unzip and download the archive as the foundry user. Replace YOUR_TIMED_URL with the URL you just copied.

sudo apt install -y unzip
sudo -u foundry wget -O /home/foundry/foundryvtt/foundryvtt.zip "YOUR_TIMED_URL"

Extract the archive and remove the zip file:

sudo -u foundry unzip /home/foundry/foundryvtt/foundryvtt.zip -d /home/foundry/foundryvtt/
sudo -u foundry rm /home/foundry/foundryvtt/foundryvtt.zip

Verify the application entry point is in place:

ls /home/foundry/foundryvtt/resources/app/main.js

If that path returns without an error, the extraction succeeded.

Step 5: Create a systemd Service

A systemd unit file keeps Foundry running as a background service and restarts it automatically after a crash or reboot.

sudo nano /etc/systemd/system/foundry.service

Paste the following configuration:

[Unit]
Description=Foundry Virtual Tabletop
Documentation=https://foundryvtt.com
After=network.target

[Service]
Type=simple
User=foundry
WorkingDirectory=/home/foundry/foundryvtt
ExecStart=/usr/bin/node /home/foundry/foundryvtt/resources/app/main.js --dataPath=/home/foundry/foundrydata
Restart=on-failure
RestartSec=5
StandardOutput=journal
StandardError=journal

[Install]
WantedBy=multi-user.target

Reload systemd so it registers the new service:

sudo systemctl daemon-reload

Hold off on starting the service for now. Get Nginx in place first.

Step 6: Configure the Firewall

Open firewall ports for SSH and web traffic. Foundry’s internal port (30000) stays closed to the public — Nginx handles all incoming connections on your behalf.

sudo ufw allow OpenSSH
sudo ufw allow 'Nginx Full'
sudo ufw enable

Confirm the rules are active:

sudo ufw status

Step 7: Install and Configure Nginx

Nginx acts as the reverse proxy that sits in front of Foundry VTT. It receives public HTTPS traffic and passes requests through to Foundry on localhost. Install it and create a server block for your domain.

sudo apt install -y nginx
sudo nano /etc/nginx/sites-available/foundry

Paste this initial HTTP configuration. Replace your_domain.com with your actual domain.

server {
    listen 80;
    server_name your_domain.com;

    location / {
        proxy_pass          http://127.0.0.1:30000;
        proxy_http_version  1.1;
        proxy_set_header    Upgrade $http_upgrade;
        proxy_set_header    Connection "upgrade";
        proxy_set_header    Host $host;
        proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header    X-Forwarded-Proto $scheme;
        proxy_cache_bypass  $http_upgrade;
        proxy_buffering     off;
        proxy_read_timeout  90s;
    }
}

The Upgrade and Connection headers let WebSocket connections pass through cleanly. The proxy_buffering off directive ensures real-time game events reach your players without sitting in a buffer.

Enable the site, test the config, and reload Nginx:

sudo ln -s /etc/nginx/sites-available/foundry /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx

Step 8: Start Foundry VTT and Activate Your License

Start the Foundry service:

sudo systemctl start foundry
sudo systemctl status foundry

Look for active (running) in the output. Open your browser and navigate to http://your_domain.com.

The license activation screen loads on first visit. Enter your license key and accept the EULA. Foundry verifies the key against its servers — this takes a few seconds. Once verified, you’ll land on the Setup screen where you can browse and install game systems.

Go ahead and install at least one game system to confirm the instance is working correctly. Then return to your terminal.

Step 9: Configure Foundry for the Reverse Proxy

Foundry VTT needs to know it’s running behind a proxy. Stop the service first so you can safely edit the configuration file:

sudo systemctl stop foundry

Foundry generated its options.json when it first started. Open it now:

sudo -u foundry nano /home/foundry/foundrydata/Config/options.json

Update the file with your domain and proxy settings:

{
  "dataPath": "/home/foundry/foundrydata",
  "hostname": "your_domain.com",
  "port": 30000,
  "proxyPort": 443,
  "proxySSL": true,
  "routePrefix": null,
  "updateChannel": "stable",
  "language": "en.core",
  "fullscreen": false,
  "upnp": false
}

Replace your_domain.com with your actual domain. Setting proxySSL to true and proxyPort to 443 tells Foundry that all public traffic arrives over HTTPS on port 443. This is essential for WebRTC voice and video features to work correctly behind the proxy.

Step 10: Obtain an SSL Certificate

Install Certbot with the Nginx plugin:

sudo apt install -y certbot python3-certbot-nginx

Request a certificate for your domain:

sudo certbot --nginx -d your_domain.com

When prompted, choose to redirect all HTTP traffic to HTTPS. Certbot modifies your Nginx configuration automatically and sets up a renewal cron job so your certificate never expires.

Step 11: Finalize the Nginx Configuration

Certbot rewrites your Nginx config to add SSL. Open the file and confirm the WebSocket headers are still present in the HTTPS server block:

sudo nano /etc/nginx/sites-available/foundry

Your final configuration should look like this. If Certbot restructured the file differently, replace its contents with the following:

server {
    listen 80;
    server_name your_domain.com;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl;
    server_name your_domain.com;

    ssl_certificate     /etc/letsencrypt/live/your_domain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/your_domain.com/privkey.pem;
    include             /etc/letsencrypt/options-ssl-nginx.conf;
    ssl_dhparam         /etc/letsencrypt/ssl-dhparams.pem;

    location / {
        proxy_pass          http://127.0.0.1:30000;
        proxy_http_version  1.1;
        proxy_set_header    Upgrade $http_upgrade;
        proxy_set_header    Connection "upgrade";
        proxy_set_header    Host $host;
        proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header    X-Forwarded-Proto $scheme;
        proxy_cache_bypass  $http_upgrade;
        proxy_buffering     off;
        proxy_read_timeout  90s;
    }
}

Test the configuration and reload Nginx:

sudo nginx -t
sudo systemctl reload nginx

Start Foundry and enable it to launch automatically on every server boot:

sudo systemctl start foundry
sudo systemctl enable foundry

Navigate to https://your_domain.com. Your browser should show a padlock in the address bar and the Foundry VTT Setup screen should load over a secure connection. Your Foundry VTT installation is complete.

How to Update Foundry VTT

Foundry releases updates regularly and major version bumps can introduce breaking changes for installed modules. Always read the release notes at foundryvtt.com before updating a live instance with active campaigns.

Step 1: Back up your data

sudo systemctl stop foundry
tar -czf ~/foundrydata-backup-$(date +%Y%m%d).tar.gz -C /home/foundry foundrydata

Step 2: Generate a fresh download URL

Log in to foundryvtt.com, navigate to Purchased Licenses, and generate a new timed URL for the latest Node.js build.

Step 3: Replace the application files

sudo -u foundry wget -O /tmp/foundryvtt-new.zip "YOUR_NEW_TIMED_URL"
sudo rm -rf /home/foundry/foundryvtt
sudo mkdir -p /home/foundry/foundryvtt
sudo -u foundry unzip /tmp/foundryvtt-new.zip -d /home/foundry/foundryvtt/
sudo -u foundry rm /tmp/foundryvtt-new.zip
sudo chown -R foundry:foundry /home/foundry/foundryvtt

Step 4: Restart the service

sudo systemctl start foundry
sudo systemctl status foundry

Visit https://your_domain.com to confirm the new version loads. Foundry displays its version number in the top-left corner of the Setup screen.

Troubleshooting Foundry VTT

The Foundry Service Fails to Start

Check the logs immediately after a failed start:

sudo journalctl -u foundry -n 50 --no-pager

The two most common culprits are an incorrect path in the ExecStart directive and a Node.js version mismatch. Verify the entry point exists at /home/foundry/foundryvtt/resources/app/main.js and that node --version returns v18 or higher.

File ownership problems also cause silent failures. If the foundry user can’t write to its own data directory, the service exits without an obvious error message. Fix ownership and try again:

sudo chown -R foundry:foundry /home/foundry
sudo systemctl restart foundry

Players See a “502 Bad Gateway” Error

A 502 means Nginx is running but can’t reach Foundry on localhost:30000. Check that the service is actually up:

sudo systemctl status foundry

If it’s stopped or in a failed state, check the journal logs for the crash reason. Also confirm your Nginx proxy_pass value is exactly http://127.0.0.1:30000. A single typo breaks the proxy without any obvious warning. Run sudo nginx -t to catch configuration syntax errors before they hit players.

WebSocket Connections Drop During Gameplay

Mid-session disconnections almost always trace back to a missing WebSocket header in Nginx. Open your server block and confirm both of these lines appear inside the location / block:

proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";

Also check your proxy_read_timeout value. The default 60-second timeout can trigger during long map loads or dice animation sequences. Set it to 90s or higher and reload Nginx with sudo systemctl reload nginx.

Foundry Isn’t Recognizing HTTPS

If Foundry generates HTTP links instead of HTTPS ones — or if WebRTC features report mixed content errors — the proxy settings in options.json need attention. Stop the service and open the file:

sudo systemctl stop foundry
sudo -u foundry nano /home/foundry/foundrydata/Config/options.json

Confirm proxySSL is true and proxyPort is 443. Save the file and restart the service. Foundry will now generate HTTPS URLs for all content and API calls.

License Verification Fails on Activation

Foundry VTT validates new license activations against its servers over HTTPS. If the verification step hangs or throws an error, check that your VPS has outbound internet access:

curl -I https://foundryvtt.com

A failed request suggests your hosting provider is blocking outbound connections on port 443. Contact support to have that resolved. Also double-check the license key itself — copy-paste errors with long alphanumeric strings are surprisingly common — and verify you haven’t exceeded the concurrent activation limit for your license tier.

What to Build Next

A working Foundry VTT instance is a strong foundation. The next upgrade worth considering is automated backups. A daily cron job that snapshots your foundrydata directory and pushes it to an S3-compatible bucket with rclone takes about 20 minutes to set up and can save an entire campaign from a failed drive.

If your group wants voice and video chat built into the game world, look into pairing Foundry’s built-in A/V client with a self-hosted TURN server using coturn. TURN handles NAT traversal for peer-to-peer WebRTC connections and keeps voice working even for players sitting behind strict firewalls.

For campaigns that stress the hardware — dozens of modules, large scene files, and a full table of players loading assets simultaneously — adding a 2 GB swap file gives Node.js extra breathing room during memory-intensive scene transitions. It won’t replace RAM but it prevents hard crashes when memory usage spikes briefly above the physical limit.

The post How to Install Foundry VTT on a VPS appeared first on GreenGeeks.

版权声明:
作者:lichengxin
链接:https://www.techfm.club/p/237162.html
来源:TechFM
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
< <上一篇
下一篇>>