Skip to content

Instantly share code, notes, and snippets.

@callunaborealis
Last active June 26, 2021 09:46
Show Gist options
  • Select an option

  • Save callunaborealis/e9ce1b52a97221c7e650a6242f36648e to your computer and use it in GitHub Desktop.

Select an option

Save callunaborealis/e9ce1b52a97221c7e650a6242f36648e to your computer and use it in GitHub Desktop.
Setting up FoundryVTT on Ubuntu 20.04.2.0 LTS (Focal Fossa)

Setting up FoundryVTT on Ubuntu 20.04.2.0 LTS (Focal Fossa)

  • Create new Ubuntu 20 instance for the Foundry server.
  • sudo apt install unzip
  • Install FoundryVTT.
  • Add start.sh script
# Start running the server (sudo needed to use 443 and 80)
cd foundryvtt && sudo nohup node resources/app/main.js --dataPath=$HOME/foundrydata &
  • Add stop.sh script
# Kills the web server assuming there isn't another Node.JS process running in the background
sudo killall -s SIGTERM node
  • Log in for the first time
  • The port is set to default as 30000. You can change it to another open port if you like.
vim foundrydata/Config/options.json
sudo apt-get update
sudo apt-get install nginx
# This is where you add the a web server config for the proxy pass
sudo vim /etc/nginx/sites-available/foundryvtt
# Set proxyPort value to the port (either 443 or 80)
vim ~/foundrydata/Config/options.json
# Enable new site
sudo ln -s /etc/nginx/sites-available/foundryvtt /etc/nginx/sites-enabled/
# Test your configuration file
sudo service nginx conftest
# Start Nginx
sudo service nginx start
# Stop Nginx
sudo service nginx stop
# Restart Nginx
sudo service nginx restart
# This goes in a file within /etc/nginx/sites-available/. By convention,
# the filename would be either "your.domain.com" or "foundryvtt", but it
# really does not matter as long as it's unique and descriptive for you.

# Define Server
server {

    # Enter your fully qualified domain name or leave blank
    server_name             your.domain.com;

    # Listen on port 443 using SSL certificates
    listen                  443 ssl;
    ssl_certificate         "/etc/letsencrypt/live/your.domain.com/fullchain.crt";
    ssl_certificate_key     "/etc/letsencrypt/live/your.domain.com/private.key";

    # Sets the Max Upload size to 300 MB
    client_max_body_size 300M;

    # Proxy Requests to Foundry VTT
    location / {

        # Set proxy headers
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;

        # These are important to support WebSockets
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";

        # Make sure to set your Foundry VTT port number
        proxy_pass http://localhost:30000;
    }
}

# Optional, but recommend. Redirects all HTTP requests to HTTPS for you
server {
    if ($host = your.domain.com) {
        return 301 https://$host$request_uri;
    }

    listen 80;
    listen [::]:80;

    server_name your.domain.com;
    return 404;
}
  • Start the server and use systemctl status nginx.service to check that there is an active reverse proxy to HTTPS.
  • Use SSLForFree to get certificates. You might get three files and need to merge 2 files (i.e. cat certificate.crt ca_bundle.crt >> cert2.crt && sudo cp cert2.crt /etc/letsencrypt/live/your.domain.com/fullchain.crt && sudo cp private.key /etc/letsencrypt/live/your.domain.com/private.key) before adding it to the NGINX site config for FoundryVTT.
  • Install Certbot, which you have to run when the SSL certificates expire (probably 90 days if using SSL For Free).

Installing FVTT-Witcher

  • Add foundryconfig.json to the base game. This file is usually git ignored by default.
  • Ensure that you run npm update instead of npm install, due to its use of its typings package being stored in GitLab instead of being registered on NPM.
  • Ensure the custom game system has dist/ not gitignored so that the distribution is available when pasting the game system system.json in the FoundryVTT Administrator panel.
  • Build and package it, ensure that the download is system.json points to the src .zip file
{
  "dataPath": "$YOUR_DIR_WHERE_THIS_REPO_IS/foundrydata", // Where foundryvtt/ is on the same level
  "systemName": "$NAME_OF_THE_GAME_SYSTEM",
  "repository": "https://github.com/$GITHUB_USERNAME/$GITHUB_REPO_NAME",
  "rawURL": "https://raw.githubusercontent.com/$GITHUB_USERNAME/$GITHUB_REPO_NAME",
  "downloadURL": "https://github.com/$GITHUB_USERNAME/$GITHUB_REPO_NAME/raw"
}

Useful links

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment