Skip to content

Deploying Focalboard self-host (post-Mattermost split) on Ubuntu 22.04

Stand up the standalone Focalboard personal-server build on Ubuntu 22.04 — PostgreSQL backend, single-user-mode disabled, nginx + Let's Encrypt, scheduled backups.

You’re standing up Focalboard for the design and product team after the Mattermost-bundled board plugin stopped getting feature parity with the standalone project. The personal-server build still ships, the binary runs, the first boards come up by lunch, and the team gets used to the layout. Six weeks later, the SQLite database in /opt/focalboard-server/data is 800 MB, the team complains about board-loading lag, two restarts during a corrupted-write incident cost a morning of work, and the original “we’ll use it in single-user-mode and figure out auth later” decision means there’s still no concept of users at all — every browser session sees every board. The standalone build was always meant for a single operator. Production multi-user use needs a different posture.

What’s happening

The Focalboard “personal server” build that survived the Mattermost split is a Go binary plus a static frontend, configurable via config.json. Two settings define whether you have a real multi-user tool or a kiosk: useSSL (false, because nginx terminates TLS) and enablePublicSharedBoards plus singleUserToken. Leaving singleUserToken blank and setting authMode: native with the registration endpoint enabled gives you proper accounts; leaving singleUserToken set turns Focalboard into a single-tenant tool that anyone with the URL can use. PostgreSQL is the production datastore — SQLite is fine for a workstation, fragile on a server because the WAL-checkpoint behavior on a shared disk under contention loses transactions when the host goes down hard. The database connection string lives in config.json; the file should be chmod 600 because the password is plaintext in there. Backups are pg_dump on the database plus a tar on files/ — board attachments live as files on disk, not as bytea columns. The Focalboard project itself is in maintenance mode (active development moved into Mattermost proper), so production deployments should pin a known-stable release and accept that the upstream cadence is slow.

How to verify

The host should expose only :443 and :22:

ss -lntp | grep -E ':(80|443|8000|5432)\b'
# 0.0.0.0:443  nginx
# 127.0.0.1:8000 focalboard
# 127.0.0.1:5432 postgres

PostgreSQL must not be reachable from the public NIC. The Focalboard config should show postgres as the datastore and single-user mode disabled:

sudo -u focalboard jq '{dbtype, dbconfig, authMode, enablePublicSharedBoards, singleUserToken}' /opt/focalboard/config.json
# {
#   "dbtype": "postgres",
#   "dbconfig": "postgres://focalboard:...@127.0.0.1:5432/focalboard?sslmode=disable",
#   "authMode": "native",
#   "enablePublicSharedBoards": false,
#   "singleUserToken": ""
# }

If singleUserToken has a value, anyone with the URL hits the same workspace and you’ve shipped a shared-everything kiosk. The HTTPS endpoint should return the login screen:

curl -sS https://board.example.com/login | grep -E 'Sign in|register' || echo "login page missing"

The API ping should be 200:

curl -sS -o /dev/null -w '%{http_code}\n' https://board.example.com/api/v2/ping
# 200

The Focalboard service should be running under its own user:

ps -o user,cmd -C focalboard-server
# USER     CMD
# focalboard /opt/focalboard/bin/focalboard-server -config /opt/focalboard/config.json

The fix

Save the script below as /root/setup-focalboard-ubuntu22.sh, then run it. It installs Focalboard on a fresh Ubuntu 22.04 VM: base hardening (UFW, SSH key-only, fail2ban, unattended-upgrades), PostgreSQL 16 on the host bound to the loopback, the Focalboard personal-server tarball deployed under /opt/focalboard, a systemd unit running as the focalboard user, multi-user mode (no singleUserToken), public board sharing disabled by default, nginx in front with Let’s Encrypt, and a nightly pg_dump + files tar.

#!/usr/bin/env bash
set -euo pipefail

### Ubuntu 22.04 Focalboard personal-server installer
### PostgreSQL 16 on the host, multi-user mode, native auth
### Keeps root SSH key login enabled
### Disables SSH password login
### Enables automatic security updates
### No local backups beyond the nightly dump; assumes VM-level backup
### Focalboard upstream is in maintenance — pin the version

if [[ "$(id -u)" -ne 0 ]]; then
  echo "Run as root."
  exit 1
fi

: "${FOCALBOARD_DOMAIN:?Set FOCALBOARD_DOMAIN=board.example.com}"
: "${FOCALBOARD_EMAIL:?Set FOCALBOARD_EMAIL=ops@example.com for Let's Encrypt}"

FOCALBOARD_VERSION="${FOCALBOARD_VERSION:-7.11.4}"
PG_PASSWORD="${PG_PASSWORD:-$(openssl rand -hex 24)}"
SESSION_SECRET="${SESSION_SECRET:-$(openssl rand -hex 32)}"

echo
echo "========================================"
echo "Focalboard Ubuntu 22.04 Setup"
echo "========================================"
echo

echo "==> Updating base OS"
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get -y upgrade

echo "==> Installing base packages"
apt-get -y install \
  vim curl wget ca-certificates gnupg2 lsb-release apt-transport-https \
  chrony fail2ban unattended-upgrades \
  ufw lsof tcpdump dnsutils tar gzip xz-utils \
  iproute2 net-tools openssl jq age \
  software-properties-common

echo "==> Enabling time sync"
systemctl enable --now chrony
timedatectl set-ntp true

echo "==> Applying kernel/network tuning"
cat > /etc/sysctl.d/99-focalboard.conf <<'SYSCTL'
net.core.default_qdisc = fq
net.ipv4.tcp_congestion_control = bbr
net.core.somaxconn = 4096
net.ipv4.tcp_max_syn_backlog = 8192
net.ipv4.tcp_syncookies = 1
net.ipv4.ip_local_port_range = 10240 65535
vm.swappiness = 10
kernel.dmesg_restrict = 1
fs.file-max = 2097152
SYSCTL
modprobe tcp_bbr || true
echo tcp_bbr > /etc/modules-load.d/bbr.conf
sysctl --system

echo "==> Setting file limits"
cat > /etc/security/limits.d/99-focalboard.conf <<'LIMITS'
focalboard soft nofile 64000
focalboard hard nofile 64000
LIMITS

echo "==> Configuring UFW"
ufw --force reset
ufw default deny incoming
ufw default allow outgoing
ufw allow 22/tcp
ufw allow 80/tcp
ufw allow 443/tcp
ufw --force enable

echo "==> Hardening SSH"
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak.$(date +%F-%H%M%S)
sed -i 's|^[#[:space:]]*PermitRootLogin.*|PermitRootLogin prohibit-password|' /etc/ssh/sshd_config
sed -i 's|^[#[:space:]]*PasswordAuthentication.*|PasswordAuthentication no|' /etc/ssh/sshd_config
sed -i 's|^[#[:space:]]*X11Forwarding.*|X11Forwarding no|' /etc/ssh/sshd_config
sshd -t && systemctl restart ssh

echo "==> Configuring fail2ban"
cat > /etc/fail2ban/jail.d/sshd.local <<'FAIL2BAN'
[sshd]
enabled = true
port = ssh
backend = systemd
maxretry = 4
findtime = 10m
bantime = 1h
FAIL2BAN
systemctl enable --now fail2ban

echo "==> Configuring unattended-upgrades"
cat > /etc/apt/apt.conf.d/20auto-upgrades <<'AUTOUPG'
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";
APT::Periodic::AutocleanInterval "7";
AUTOUPG

echo "==> Installing PostgreSQL 16"
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc \
  | gpg --dearmor -o /etc/apt/keyrings/postgres.gpg
echo "deb [signed-by=/etc/apt/keyrings/postgres.gpg] https://apt.postgresql.org/pub/repos/apt jammy-pgdg main" \
  > /etc/apt/sources.list.d/pgdg.list
apt-get update
apt-get -y install postgresql-16 postgresql-contrib-16

systemctl enable --now postgresql

sudo -u postgres psql <<SQL
CREATE USER focalboard WITH PASSWORD '${PG_PASSWORD}';
CREATE DATABASE focalboard OWNER focalboard ENCODING 'UTF8' LC_COLLATE 'en_US.UTF-8' LC_CTYPE 'en_US.UTF-8' TEMPLATE template0;
SQL

sed -i "s/^#\?listen_addresses.*/listen_addresses = 'localhost'/" /etc/postgresql/16/main/postgresql.conf
sed -i "s/^#\?password_encryption.*/password_encryption = scram-sha-256/" /etc/postgresql/16/main/postgresql.conf
systemctl restart postgresql

echo "==> Creating focalboard system user"
useradd -r -m -d /opt/focalboard -s /usr/sbin/nologin focalboard || true

echo "==> Fetching Focalboard ${FOCALBOARD_VERSION}"
mkdir -p /opt/focalboard
cd /tmp
curl -fsSL -o focalboard.tar.gz \
  "https://github.com/mattermost/focalboard/releases/download/v${FOCALBOARD_VERSION}/focalboard-server-linux-amd64.tar.gz"
tar xzf focalboard.tar.gz
rsync -a focalboard/ /opt/focalboard/
rm -rf focalboard focalboard.tar.gz

mkdir -p /var/lib/focalboard/files
chown -R focalboard:focalboard /opt/focalboard /var/lib/focalboard

cat > /opt/focalboard/config.json <<EOF
{
  "serverRoot": "https://${FOCALBOARD_DOMAIN}",
  "port": 8000,
  "dbtype": "postgres",
  "dbconfig": "postgres://focalboard:${PG_PASSWORD}@127.0.0.1:5432/focalboard?sslmode=disable",
  "postgres_dbconfig": "postgres://focalboard:${PG_PASSWORD}@127.0.0.1:5432/focalboard?sslmode=disable",
  "useSSL": false,
  "webpath": "./pack",
  "filespath": "/var/lib/focalboard/files",
  "telemetry": false,
  "session_expire_time": 2592000,
  "session_refresh_time": 18000,
  "localOnly": false,
  "enableLocalMode": false,
  "localModeSocketLocation": "/var/tmp/focalboard_local.socket",
  "enablePublicSharedBoards": false,
  "authMode": "native",
  "singleUserToken": "",
  "logging_cfg_file": "",
  "loggingCfgFile": "",
  "sessionSecret": "${SESSION_SECRET}"
}
EOF

chown focalboard:focalboard /opt/focalboard/config.json
chmod 600 /opt/focalboard/config.json

echo "==> Installing Focalboard systemd unit"
cat > /etc/systemd/system/focalboard.service <<'FB'
[Unit]
Description=Focalboard personal server
After=network.target postgresql.service
Wants=postgresql.service

[Service]
Type=simple
User=focalboard
Group=focalboard
WorkingDirectory=/opt/focalboard
ExecStart=/opt/focalboard/bin/focalboard-server -config /opt/focalboard/config.json
Restart=on-failure
RestartSec=5
LimitNOFILE=64000
NoNewPrivileges=true
PrivateTmp=true
ProtectSystem=full
ProtectHome=true
ReadWritePaths=/var/lib/focalboard /opt/focalboard

[Install]
WantedBy=multi-user.target
FB

systemctl daemon-reload
systemctl enable --now focalboard

echo "==> Waiting for Focalboard on 127.0.0.1:8000"
for i in {1..60}; do
  if ss -lntp | grep -q '127.0.0.1:8000'; then break; fi
  sleep 2
done

if ! ss -lntp | grep -q '127.0.0.1:8000'; then
  echo "Focalboard failed to listen on 127.0.0.1:8000"
  journalctl -u focalboard --no-pager -n 200 || true
  exit 1
fi

echo "==> Installing nginx + certbot"
apt-get -y install nginx certbot python3-certbot-nginx

cat > /etc/nginx/sites-available/focalboard <<NGINX
upstream focalboard_backend {
    server 127.0.0.1:8000;
    keepalive 32;
}

server {
    listen 80;
    listen [::]:80;
    server_name ${FOCALBOARD_DOMAIN};
    return 301 https://\$host\$request_uri;
}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name ${FOCALBOARD_DOMAIN};

    client_max_body_size 100M;
    proxy_read_timeout   600s;
    proxy_send_timeout   600s;

    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
    add_header X-Content-Type-Options nosniff always;
    add_header X-Frame-Options SAMEORIGIN always;
    add_header Referrer-Policy strict-origin-when-cross-origin always;

    # Websockets for board collaboration
    location /ws/ {
        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;
        proxy_set_header Upgrade \$http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_http_version 1.1;
        proxy_read_timeout 3600s;
        proxy_send_timeout 3600s;
        proxy_pass http://focalboard_backend;
    }

    location / {
        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;
        proxy_http_version 1.1;
        proxy_pass http://focalboard_backend;
    }
}
NGINX

ln -sf /etc/nginx/sites-available/focalboard /etc/nginx/sites-enabled/focalboard
rm -f /etc/nginx/sites-enabled/default

nginx -t
systemctl enable --now nginx
systemctl reload nginx

echo "==> Requesting Let's Encrypt certificate"
certbot --nginx --non-interactive --agree-tos \
  -m "${FOCALBOARD_EMAIL}" -d "${FOCALBOARD_DOMAIN}" --redirect

systemctl enable --now certbot.timer

echo "==> Installing daily encrypted backup job"
mkdir -p /var/backups/focalboard
chmod 700 /var/backups/focalboard

age-keygen -o /opt/focalboard/backup.key
chmod 600 /opt/focalboard/backup.key
chown focalboard:focalboard /opt/focalboard/backup.key
BACKUP_RECIPIENT=$(grep '# public key:' /opt/focalboard/backup.key | awk '{print $4}')

cat > /usr/local/sbin/focalboard-backup.sh <<EOF
#!/usr/bin/env bash
set -euo pipefail
TS=\$(date +%F-%H%M)
DEST=/var/backups/focalboard
sudo -u postgres pg_dump -Fc focalboard \\
  | age -r ${BACKUP_RECIPIENT} > "\${DEST}/focalboard-\${TS}.dump.age"
tar -czf - -C /var/lib/focalboard files \\
  | age -r ${BACKUP_RECIPIENT} > "\${DEST}/focalboard-files-\${TS}.tar.gz.age"
find "\${DEST}" -name 'focalboard-*' -mtime +14 -delete
EOF
chmod 700 /usr/local/sbin/focalboard-backup.sh

cat > /etc/systemd/system/focalboard-backup.service <<'EOF'
[Unit]
Description=Focalboard encrypted backup
After=postgresql.service focalboard.service

[Service]
Type=oneshot
ExecStart=/usr/local/sbin/focalboard-backup.sh
EOF

cat > /etc/systemd/system/focalboard-backup.timer <<'EOF'
[Unit]
Description=Daily Focalboard backup

[Timer]
OnCalendar=*-*-* 03:25:00
RandomizedDelaySec=900
Persistent=true

[Install]
WantedBy=timers.target
EOF

systemctl daemon-reload
systemctl enable --now focalboard-backup.timer

echo "==> Final package update"
apt-get -y upgrade

echo
echo "========================================"
echo "DONE"
echo "========================================"
echo
echo "Listeners:"
ss -lntp | grep -E ':(80|443|5432|8000)\b' || true
echo
echo "SSH effective settings:"
sshd -T | grep -E '^(permitrootlogin|passwordauthentication|pubkeyauthentication) ' || true
echo
echo "Focalboard services:"
systemctl is-active focalboard postgresql nginx fail2ban
echo
echo "Backup recipient (keep this!):"
echo "${BACKUP_RECIPIENT}"
echo
echo "Web UI:"
echo "https://${FOCALBOARD_DOMAIN}/"
echo
echo "First steps:"
echo "1. Open the URL — the first sign-up becomes the admin account."
echo "2. After the first account is created, set 'authMode: native' alone is not enough — disable registration if you want closed enrollment:"
echo "   Edit /opt/focalboard/config.json and set 'registrationEnabled': false (Focalboard reads it from the registrationOpen team setting after first boot)."
echo "3. Confirm singleUserToken is empty — anyone with the URL would otherwise see all boards."

Make it executable and run it:

chmod 700 /root/setup-focalboard-ubuntu22.sh
FOCALBOARD_DOMAIN=board.example.com \
FOCALBOARD_EMAIL=ops@example.com \
/root/setup-focalboard-ubuntu22.sh

The first user to register at https://board.example.com/register becomes the admin — claim that account immediately, then close registration through the team settings menu so further invites go through the admin rather than self-signup. Confirm singleUserToken stays empty in config.json (Focalboard reads it at start time) — set values turn the deployment back into a kiosk where every browser sees the same workspace. Pin the version in the script (FOCALBOARD_VERSION) and revisit it deliberately; the upstream project is in maintenance mode after the Mattermost split, so most production deployments hold on a known-stable release rather than chasing the latest tag. Keep the age private key (/opt/focalboard/backup.key) somewhere off this host — without it, the nightly encrypted dumps are unreadable.

For a Focalboard tier you don’t have to operate yourself, run it on our managed cloud compute with patching, monitoring, and Sev-1 escalation in place — or start a scoping call if you’d like us to plan the deployment and version-pin strategy.