Skip to contents

How the one server behind tl-data.teachinglab.org and api.teachinglab.org is built and run, and what bites when you rebuild or change it. Unfinished server work is in OPEN_WORK.md. The reasons behind the current setup are in DECISIONS.md. For what is deployed on it, see ARCHITECTURE.md.

Rebuilt from scratch on Ubuntu 26.04 and cut over on 2026-11-17. The old 22.04 server was in place from 2024 until then and was terminated on 2026-11-21.

What it is

Instance i-0e17bedb930c95fef, Name=tl-posit-connect, t3.2xlarge, us-east-2a
Address Elastic IP 3.131.192.25 (eipalloc-06182e5e0449b74b3); both hostnames point at it
Security group sg-056f4242e7576f848: inbound 22, 80 and 443 only. 3939 (Connect) and 8000 (tl-api) stay closed and are reached only through Caddy
OS Ubuntu 26.04 LTS (Posit support to 2031)
Backups DLM policy policy-0b29b3379c09cf41c: daily snapshot at 08:00 UTC, keeps 7, targets the Name=tl-posit-connect tag
Audit log CloudTrail trail management-events (since 2026-11-23): all regions, management events only (no data events, so free), log file validation on, delivered to s3://tl-cloudtrail-749572964452
AWS account 749572964452. aws login --profile teachinglab signs in as root, so every change raises a GuardDuty RootCredentialUsage finding
SSH ssh 3.131.192.25 with the posit-connect key, as ubuntu (key-only). Port 22 is open only to allowlisted IPs; run scripts/ssh_allow.sh add from a new network. fail2ban (/etc/fail2ban/jail.local) bans repeated failures, and the home IP is exempt

What runs on it

  • Posit Connect, apt package rstudio-connect, kept on hold (apt-mark hold), so it only moves when someone upgrades it on purpose.
    • Data is in /var/lib/rstudio-connect and config in /etc/rstudio-connect/rstudio-connect.gcfg.
    • Server log: /var/log/rstudio/rstudio-connect/rstudio-connect.log. journalctl shows only the first few lines.
    • The [Applications] Supervisor wrapper, /opt/scripts/connect-env-supervisor.sh, exports every server-wide secret (AWS, Qualtrics, Slack, OpenAI, Azure, Monday, Cue Coach) into each content process. It is 750 root:rstudio-connect (since 2026-11-23): Connect’s connect-session runs it as rstudio-connect, so that group needs read and execute, and other accounts don’t get either. If you recreate it, restore that mode, or every app fails to start. A credential rotation means editing this file. New processes pick up the change; restart Connect to move every running process over.
  • R 4.3.3 and 4.4.1 at /opt/R/<ver> (Posit builds for ubuntu-2604). /usr/local/bin/R and Rscript point at 4.3.3, which tl-api uses.
  • Python 3.10, 3.11 and 3.12, installed with uv at /opt/python/cpython-<ver>-linux-x86_64-gnu/ and listed in the gcfg. Posit no longer builds Python. Content asking for an older patch version matches by minor version.
  • Quarto 1.8.26 at /opt/quarto/1.8.26, linked to /usr/local/bin/quarto.
  • Caddy terminates TLS for both hostnames (Let’s Encrypt) and proxies to Connect (:3939) and tl-api (:8000). Its config is /etc/caddy/Caddyfile. For monday-webhook, a @webhook_token rule moves ?token= into an X-Webhook-Token header and strips it from the URL before proxying, so the shared secret never lands in Connect’s access log (2026-11-18). It sits inside route because Caddy otherwise runs uri before request_header. Backup: /etc/caddy/Caddyfile.bak-2026-11-18. The /mcp* block rewrites Host to localhost:3939, because Connect’s MCP server rejects the public hostname.
  • tl-api (/home/ubuntu/plumber-apis, the plumber API behind api.teachinglab.org). It runs under pm2 as run-my-plumber, and the pm2-ubuntu systemd unit starts pm2 at boot. There is no crontab. Logs are in ~/.pm2/logs/run-my-plumber-{out,error}.log. Its /update/update_survey_s3 route runs the Qualtrics→S3 scripts in /home/ubuntu/scripts (ec2_tl_scripts).
  • Plumber log files for the Connect APIs are in /var/log/plumber/, readable by root only. The Plumber Logging dashboard (/monday_webhook_api_dashboard/) reads them.

Not installed, deliberately: osTicket/PHP, Chronicle, Docker, CUPS, Java, Chrome, lxd/helm, system R and old Pythons. They were all dead on the old server.

Changing things

Upgrading Connect. Check the release notes for removed settings and CONNECT_* variables first. Then:

sudo systemctl stop rstudio-connect
sudo cp -a /var/lib/rstudio-connect/db /home/ubuntu/connect-db-bak-<date>
sudo cp -a /etc/rstudio-connect/rstudio-connect.gcfg /etc/rstudio-connect/rstudio-connect.gcfg.bak-<old ver>
sudo apt-mark unhold rstudio-connect
sudo apt-get install rstudio-connect=<ver> -o Dpkg::Options::=--force-confold
sudo apt-mark hold rstudio-connect
sudo systemctl start rstudio-connect

After the restart, grep the server log for level=warning. A broken git credential, for example, shows up only as a warning: Connect disables every credential for a host when two [GitCredential] sections share it. Then check /mcp/ (it should return 401 without auth, not 403) and load the live apps. The last upgrade was 2026.10.0 → 2026.11.0 on 2026-11-17.

Rotating a secret. Edit the supervisor script, then sudo systemctl restart rstudio-connect. For tl-api, the secrets are in /home/ubuntu/.Renviron; restart it with pm2 restart run-my-plumber.

Rebooting is safe. Connect, Caddy and tl-api (through pm2-ubuntu) come back on their own in under a minute.

Gotchas found in the 2026 rebuild

Read this before rebuilding the server again or copying Connect’s data anywhere.

  • R packages pinned to versions with no 26.04 binary have to compile, and some no longer can. later < 1.4.8 doesn’t compile against glibc 2.43, and Posit Package Manager has 26.04 binaries only for current versions. When the server was rebuilt, 37 live items had their bundle’s manifest.json bumped to later 1.4.8 and nothing else. An archived item that gets unarchived may need the same bump.
  • The gcfg needs [RPackageRepository "CRAN"] pointing at https://packagemanager.posit.co/cran/latest as well as PositPackageManagerURLRewriting = force-binary. Bundles pin CRAN/cran.rstudio.com, and force-binary doesn’t rewrite those, so without that section every package compiles from source.
  • A copied Connect package cache can contain packages that crash at load. Connect’s packrat cache (/var/lib/rstudio-connect/packrat) keys entries by package hash, not by OS. When the old server’s cache was copied over, 41 compiled entries (stringi, xml2, magick, ragg, igraph, pdftools, sodium) were still linked to 22.04 libraries such as libicu70 and libxml2.so.2. Builds reported success because they reuse cache entries without loading them. The apps then died at startup. To detect this, run ldd on every *.so under packrat/, with /opt/R/<ver>/lib/R/lib on LD_LIBRARY_PATH (otherwise every entry shows libR.so as not found). Move the bad entries away and rebuild.
  • showtext segfaults on 26.04. FreeType 2.14 returns Raster_Overflow, and showtext 0.9-7 dereferences the null bitmap. ongoing_report, student_work_graded and ongoing_report_24_25 now use systemfonts + ragg instead (commits cd11ffa6, bbc595b5, d254efe9). Don’t add showtext to new apps.
  • Archived content can’t be rebuilt. The API returns 403. That’s harmless, because archived items aren’t served.
  • uid/gid differ between servers. If you copy data from a mounted disk, numeric ids are kept, so map them with rsync --usermap/--groupmap.
  • Connect intercepts Authorization: Bearer as its own API key and returns 401 before the content runs. Content with its own token auth has to use a custom header (X-Cue-Coach-Token) or a query parameter.