Systemd Deployment
PRISM can run as a native systemd service for bare-metal or VM deployments.
:::note The packages ship this unit
apt install prism / dnf install prism installs /usr/lib/systemd/system/prism.service
with EnvironmentFile=-/etc/default/prism, MemoryMax=6G and the sandboxing described below — the copy below
is for reference and manual installs. A unit in /etc/systemd/system overrides the packaged unit; use systemctl edit prism for local overrides.
:::
Package Installation
Debian / Ubuntu
sudo dpkg -i prism_1.4.7_amd64.deb
RHEL / Fedora / CentOS
sudo rpm -i prism-1.4.7-1.x86_64.rpm
Both packages install:
- Binary:
/usr/bin/prism(where the deb/rpm packages install it) - Config:
/etc/prism/config.toml - Environment defaults:
/etc/default/prism - Licence terms:
/usr/share/doc/prism/LICENSE(supply your own signed licence file) - Service:
/usr/lib/systemd/system/prism.service
Systemd Service File
[Unit]
Description=PRISM Dynamic Rendering Proxy
Documentation=https://github.com/Trident-Cache/prism
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=prism
Group=prism
EnvironmentFile=-/etc/default/prism
ExecStart=/usr/bin/prism --config ${PRISM_CONFIG}
Restart=on-failure
RestartSec=5s
# Startup timeout
TimeoutStartSec=30
# Give the graceful shutdown path room to drain in-flight renders and tear
# Chrome down. Must exceed server.drain_timeout_secs in the PRISM config.
TimeoutStopSec=60
# Security hardening
AmbientCapabilities=CAP_NET_BIND_SERVICE
NoNewPrivileges=true
ProtectSystem=strict
ProtectHome=true
ReadWritePaths=/var/lib/prism /var/log/prism
# /run/prism: where a generated admin token is written (prism-admin-token)
RuntimeDirectory=prism
RuntimeDirectoryMode=0750
PrivateTmp=true
PrivateDevices=true
ProtectKernelTunables=true
ProtectKernelModules=true
ProtectControlGroups=true
ProtectKernelLogs=true
ProtectClock=true
ProtectHostname=true
LockPersonality=true
RestrictRealtime=true
RestrictSUIDSGID=true
# Chrome needs /dev/shm and /tmp
ReadWritePaths=/dev/shm
# Reach and privilege of the process tree.
#
# Every directive in this block was added to the unit as shipped and judged by
# dist/integration-testing/test-systemd-hardening.sh: start under real systemd,
# a crawler gets a rendered page, restart, a crawler gets one again, with
# Chrome's own sandbox engaged. Re-run it after changing any of them — a
# directive that breaks Chrome's sandbox leaves `systemctl status` saying
# "active" while every crawler gets a 503.
# The only capability PRISM uses is binding a port below 1024 (server.address
# = "0.0.0.0:80"). Chrome's sandbox needs none: the user namespace it creates
# grants it a full set inside that namespace whatever is held out here.
CapabilityBoundingSet=CAP_NET_BIND_SERVICE
# PRISM and Chrome speak TCP, Unix sockets, and netlink (Chrome watches for
# network changes through it). Nothing else is opened.
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 AF_NETLINK
SystemCallArchitectures=native
# Other people's processes are not PRISM's business. /proc/<pid> of its own
# Chrome children stays visible, which is all the memory accounting reads.
ProtectProc=invisible
# Chrome's sandbox creates user, PID and network namespaces; the rest of the
# namespace types are refused.
RestrictNamespaces=user pid net
# @system-service, plus the four calls Chromium makes that it leaves out. Each
# was found by a Chrome process dying of SIGSYS on it: pkey_alloc and
# pkey_mprotect (PartitionAlloc's memory protection keys; pkey_free is the same
# feature), then chroot (the sandbox puts the renderer in an empty root before
# it drops everything). Allowing @privileged or @mount instead would give back
# far more than the sandbox uses.
SystemCallFilter=@system-service pkey_alloc pkey_free pkey_mprotect chroot
# Deliberately not set, because each broke rendering when tried:
# MemoryDenyWriteExecute=yes V8 compiles JavaScript to writable-and-executable
# memory; Chrome aborts at start.
# RestrictNamespaces=yes Chrome exits during start: the sandbox cannot
# create its namespaces.
# RestrictNamespaces=user pid The same: the sandbox needs a network namespace too.
# ProcSubset=pid Chrome starts on Fedora but not on Debian: its
# chromium wrapper script reads /proc/cpuinfo
# ("grep: /proc/cpuinfo: No such file"). PRISM
# itself reads /proc/meminfo for the memory limit
# it sizes the recycle threshold against when the
# cgroup shows none.
# SystemCallFilter=@system-service alone
# The zygote dies of SIGSYS; Chrome logs "Zygote
# process exited prematurely".
# Resource limits — Chrome is memory hungry.
#
# Measured: ~1.5 GiB resident for a 4-tab pool under sustained load (see the
# soak test in tests/pool_tests.rs), i.e. roughly 375 MiB per tab plus ~400 MiB
# of base overhead. This value is sized for the shipped default of
# render.pool.tabs = 8; if you lower `tabs`, you can lower this with it.
#
# PRISM checks this at startup and warns if the budget cannot fit the
# configured pool, so a mismatch shows up in the log rather than as an
# OOM kill plus a Restart=on-failure loop.
LimitNOFILE=65535
LimitNPROC=4096
MemoryMax=6G
# Chrome is thread-hungry, and threads count as tasks. Measured with Chromium
# 156: about 470 tasks with 8 concurrent plain renders (the whole default
# pool), about 1100 with 8 concurrent heavy pages, each with five cross-site
# frames in their own renderer processes — roughly 140 per heavy tab. 4096 is
# nearly four times that, matches LimitNPROC above, and stops a runaway from
# spending the host's whole process table. If you raise render.pool.tabs well
# past 8, raise this with it.
TasksMax=4096
# When the kernel OOM-kills a process in this unit, keep the unit running.
#
# The process that gets killed is a Chrome renderer — it is by far the largest
# thing here. systemd's default (OOMPolicy=stop) answers that by stopping the
# whole unit, which takes the proxy down with the renderer: every visitor to
# the site loses it over one heavy page. PRISM notices a dead Chrome within
# seconds and replaces it on its own, and the proxy never needed it to serve
# visitors, so the right response to a renderer dying is to carry on.
#
# PRISM also recycles Chrome before it gets this far
# (render.pool.recycle_at_memory_percent, 80% of MemoryMax by default).
OOMPolicy=continue
[Install]
WantedBy=multi-user.target
Setup
For a manual installation, save the unit as /etc/systemd/system/prism.service, create /etc/default/prism with PRISM_CONFIG=/etc/prism/config.toml, and create /var/lib/prism and /var/log/prism owned by prism. Package installation supplies these files and directories.
Create Service User
sudo useradd --system --no-create-home --shell /usr/sbin/nologin prism
Chrome Sandbox Requirements
PRISM runs Chrome with sandbox enabled for security. The sandbox uses Linux user namespaces, which requires:
# Check if user namespaces are enabled (should return 1)
sysctl kernel.unprivileged_userns_clone
If the value is 0, enable it:
# Enable temporarily
sudo sysctl -w kernel.unprivileged_userns_clone=1
# Enable permanently
echo "kernel.unprivileged_userns_clone=1" | sudo tee /etc/sysctl.d/99-chrome-sandbox.conf
sudo sysctl --system
Most modern distributions (Ubuntu 18.04+, Fedora 31+, Debian 12+, RHEL 9+) have this enabled by default. Some hardened hosting environments or older kernels may have it disabled — check with your hosting provider if Chrome fails to start with a sandbox error.
The packaged unit sets RestrictNamespaces=user pid net, which is exactly what Chromium's sandbox creates, and CapabilityBoundingSet=CAP_NET_BIND_SERVICE. If Chrome fails to start under it with a sandbox error, that is where to look first: systemctl edit prism and set RestrictNamespaces= (empty) to test, then report the Chromium version.
Install Chrome
PRISM requires Chromium or Google Chrome. Install the system package:
# Debian/Ubuntu
sudo apt install chromium-browser
# RHEL/Fedora
sudo dnf install chromium
PRISM finds the browser in this order:
- The
CHROMEenvironment variable, if set. - The
CHROME_PATHenvironment variable, if it is set and names an existing file. Set it in/etc/default/prism, for exampleCHROME_PATH=/usr/bin/chromium. If it names a file that does not exist, PRISM logs a warning and carries on with the next step. - The first of the usual browser names (
google-chrome,chromium,chromium-browserand similar) found onPATH.
When the browser comes from CHROME_PATH, PRISM logs the path once at startup at INFO level.
Configure
Edit /etc/prism/config.toml with your origin and settings. Place your license key at /etc/prism/license.lic.
Enable and Start
sudo systemctl daemon-reload
sudo systemctl enable prism
sudo systemctl start prism
Check Status
sudo systemctl status prism
sudo journalctl -u prism -f
Security Hardening Explained
| Directive | Purpose |
|---|---|
NoNewPrivileges=true | Prevents privilege escalation via setuid binaries |
ProtectSystem=strict | Mounts the filesystem read-only except explicitly allowed paths |
ProtectHome=true | Makes /home, /root, /run/user inaccessible |
PrivateTmp=true | Isolates /tmp and /var/tmp |
ProtectKernelTunables=true | Denies write access to /proc and /sys kernel tunables |
ProtectKernelModules=true | Prevents loading kernel modules |
ProtectKernelLogs=true, ProtectClock=true, ProtectHostname=true | No kernel log buffer, no clock changes, no hostname changes |
LockPersonality=true, RestrictRealtime=true, RestrictSUIDSGID=true | No execution-domain changes, no realtime scheduling, no setuid/setgid files |
CapabilityBoundingSet=CAP_NET_BIND_SERVICE | The one capability PRISM uses: binding a port below 1024. Chrome's sandbox needs none |
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 AF_NETLINK | Only TCP, Unix sockets and netlink |
SystemCallArchitectures=native | No 32-bit system-call entry points |
SystemCallFilter=@system-service pkey_alloc pkey_free pkey_mprotect chroot | The standard service set plus the four calls Chromium makes that it excludes. Found by running Chromium under the filter and reading which call killed it |
RestrictNamespaces=user pid net | The namespaces Chrome's sandbox creates, and no others |
ProtectProc=invisible | PRISM sees only its own processes in /proc |
TasksMax=4096 | Chrome counts threads as tasks: about 470 for 8 simple renders, about 1100 for 8 heavy pages with cross-site frames. Raise it if you raise render.pool.tabs well past 8 |
MemoryMax=6G | Hard memory limit -- OOM-killed if exceeded |
OOMPolicy=continue | An OOM kill inside the unit (in practice a Chrome renderer) does not stop the unit. With systemd's default, stop, one killed renderer takes the proxy down for every visitor. PRISM replaces a dead Chrome itself, and recycles it at render.pool.recycle_at_memory_percent (80% of the limit) before the kernel has to act. Needs systemd 243 or newer; older versions ignore the line and already behave this way |
Left out on purpose: MemoryDenyWriteExecute=yes (V8 needs writable-and-executable memory; Chrome aborts at start), ProcSubset=pid (Debian's Chromium wrapper script reads /proc/cpuinfo, and PRISM reads /proc/meminfo to find the memory limit when the cgroup shows none), and any wider SystemCallFilter or RestrictNamespaces.
Checking the unit against real Chrome
A directive that breaks Chrome's sandbox leaves systemctl status saying "active" while every crawler gets a 503, so the unit is tested by running it:
dist/integration-testing/test-systemd-hardening.sh # the shipped unit
dist/integration-testing/test-systemd-hardening.sh --sweep # and each candidate directive alone
dist/integration-testing/test-systemd-hardening.sh --distro=debian
It builds the package, installs it in a privileged container running systemd as PID 1 with a distribution Chromium, and requires a rendered page for a crawler, the origin's own page for a visitor, the same after systemctl restart, parallel and heavy renders, a visitor served with no browser installed, a clean systemctl stop with renders in flight, and a privileged port. It takes about two minutes (a --sweep about ten more). Re-run it whenever you change a directive; tests/systemd_unit.rs pins the set it proved.
Log Management
PRISM logs to stdout/stderr, which systemd captures in the journal. For JSON-structured logging:
[logging]
format = "json"
level = "info"
To forward logs to a file:
sudo journalctl -u prism -o cat >> /var/log/prism/prism.log
Or configure journald forwarding to syslog/rsyslog for centralized log management.