www application architecture
cms.nri-inc.org runs on vm-nri-www: Caddy in front of Kestrel, Umbraco 17
on SQLite, a Node child process for Svelte server-side rendering, Azure Blob
Storage for media and Azure Key Vault for secrets. This page describes the
application on the host. The Azure resources around it — resource groups,
network security group, vaults, storage accounts, monitoring — are inventoried
on NRI Inc on Azure. Releases are covered under
Deploying. Building the server from scratch is on
Provisioning the VM, and connection problems on
SSH reliability.
Posture at a glance
Section titled “Posture at a glance”| Control | Status | Note |
|---|---|---|
| Application exposure | ✅ | Kestrel on 127.0.0.1:5019 and Caddy’s admin API on loopback; only Caddy accepts outside traffic, and only from Cloudflare — The request path |
| Origin TLS | ⚠️ | Cloudflare connects in Full mode, which encrypts but does not validate the origin certificate; Full (strict) would — The request path |
| Service privileges | ✅ | Runs as www-data with NoNewPrivileges and UMask=0027 — The request path |
| SSH authentication | ✅ | Ed25519 key only, no password login on any account, no root key — SSH authentication |
| Secrets on disk | ✅ | Application secrets come from Key Vault through the managed identity; one backup credential file remains on disk — Application secrets |
| Patching | ⚠️ | Unattended security upgrades; automatic reboot off, so kernel updates wait for a manual reboot — Patching |
| Database backups | ⚠️ | Daily, verified, uploaded; a restore has not been proven — Backups |
| Key-person risk | ⚠️ | One SSH key, one holder — Where the private key is kept |
| Application directory | ⚠️ | Owned by www-data, so the application can modify its own deployed code — Provisioning |
| Service hardening | ⚠️ | No ProtectSystem, PrivateTmp or capability bounding on the unit — Provisioning |
| Backup credential file | ❌ | /etc/nri-inc-backup.env exists only on the VM and is not backed up by anything — Data |
| Application-level alerting | ❌ | Nothing alerts on the service crashing, a failed backup or a full disk — Logging |
The request path
Section titled “The request path”flowchart LR V[Visitor] --> CF[Cloudflare<br/>DNS · CDN · cache · TLS at the edge] CF -->|TLS| NSG OP[Operator /32] -->|SSH, key only, :22| NSG AZ[Azure Contributor] -.->|run-command as root,<br/>no SSH, no NSG| VM subgraph VM[vm-nri-www] NSG[NSG: 443 from Cloudflare,<br/>22 from one address] --> C[Caddy<br/>TLS, Cloudflare origin cert] C -->|loopback| K[Kestrel 127.0.0.1:5019<br/>www-data] K --> N[Node child process<br/>Svelte SSR] K --> DB[(SQLite on the OS disk)] end K --> B[(Blob Storage: media)] K -->|managed identity| KV[(Key Vault: secrets)]Three things make the box safe to expose at all:
- The application never listens on a public interface. Kestrel is bound to
127.0.0.1:5019by the service unit. The only process accepting traffic from outside is Caddy. - Only Cloudflare reaches the box. The NSG accepts 443 from Cloudflare’s
ranges only and drops port 80. Cloudflare redirects
http://tohttps://at the edge and connects to the origin over TLS in Full mode. - Caddy terminates TLS with a Cloudflare origin certificate. The
certificate and key are in
/etc/caddy/certsand are valid until October 2041, so nothing renews. Caddy reverse-proxies to Kestrel and setsX-Forwarded-For,X-Forwarded-ProtoandX-Forwarded-Hostand preserves the originalHostheader, which is what lets Umbraco resolve its hostname-based site roots. - The application runs unprivileged.
nri-inc.serviceruns aswww-data:www-datawithNoNewPrivileges=trueandUMask=0027. It can read its secrets file; it cannot write it, and it cannot gain privileges through setuid binaries.
There is no web application firewall or rate limiting on the VM; Cloudflare
provides the edge controls. Caddy sets no security headers
(Strict-Transport-Security, X-Content-Type-Options, Referrer-Policy); the
only headers the site adds are Cloudflare’s own. Caddy to Kestrel is plaintext
over the loopback interface only.
The host
Section titled “The host”| Machine | vm-nri-www — 2 vCPU, 4 GiB RAM, x86-64, Ubuntu 26.04 LTS |
| Login | azureuser (key only), sudo without a password |
| App directory | /var/www/nri-inc.org |
| Service | nri-inc.service on 127.0.0.1:5019 |
| Swap | 4 GiB file at /swapfile, vm.swappiness=10 |
The architecture is x86-64. The Makefile publishes linux-x64, so make deploy targets it correctly; a linux-arm64 build would produce an
application that cannot start here.
| Data | Where it lives | Backed up |
|---|---|---|
| Content and settings | umbraco/Data/Umbraco.sqlite.db |
Yes — see Backups |
| Umbraco Automate | umbraco/Data/Umbraco.Automate.sqlite.db |
Yes |
| Media, image cache, DataProtection keys | Azure Blob Storage | 30-day soft delete; versioning off by design, LRS |
| Logs | umbraco/Logs/ |
No |
| Application secrets | Azure Key Vault | Versioned, 90-day soft delete |
| Backup job credential | /etc/nri-inc-backup.env |
No |
/var/www/nri-inc.org/umbraco/ holds the databases, the logs and the Examine
indexes. The deploy excludes it, so a release never touches live data.
/etc/nri-inc-backup.env (root:root, mode 600) holds the backup storage
account key. It is read by the backup shell script rather than the
application, so Key Vault does not cover it and the VM holds the only copy.
Fetching the key with az keyvault secret show under the same managed identity
would bring it under the vault.
SSH authentication
Section titled “SSH authentication”Key only. Check with sshd -T:
| Setting | Value |
|---|---|
passwordauthentication |
no |
kbdinteractiveauthentication |
no |
pubkeyauthentication |
yes |
permitrootlogin |
prohibit-password |
The key is an Ed25519 key. There is no password on any account that can be used
to log in, so password guessing is not an available attack regardless of rate
limiting. Root cannot log in with a password, and no key is installed for
root. Operator access is azureuser plus sudo, and sudo asks for no
password, so the SSH key alone is root.
There is no intrusion detection or file integrity monitoring, and no
fail2ban. OpenSSH’s own per-source penalties cover the latter role, and with
password authentication disabled and port 22 restricted to one address, there
is very little for it to do.
Where the private key is kept
Section titled “Where the private key is kept”In the macOS login Keychain, as the generic password
vm-nri-www-azure-ssh-key (base64-encoded, since the Keychain mangles some
binary payloads), with a second copy in Proton Pass. It is deliberately not
stored as a file on disk. Load it into the agent when it is needed:
security find-generic-password -a "$USER" -s vm-nri-www-azure-ssh-key -w \ | base64 -d | ssh-add -An agent-held key does not survive a reboot, so that command is needed again
after one. With the key in the agent, make deploy needs no SSH_KEY at all —
ssh falls back to the agent when no identity file is given.
Application secrets
Section titled “Application secrets”Secrets live in Azure Key Vault, and the application reads them at startup through the VM’s system-assigned managed identity. The vaults themselves, their roles and how to set a secret are on the Azure page.
Key Vault plugs into .NET’s configuration system rather than into Umbraco.
Umbraco reads everything through IConfiguration and never knows where a value
came from, so no composer, startup filter or Umbraco package is involved.
Program.cs registers the provider last, so vault values win over the
appsettings files:
string? keyVaultUri = builder.Configuration["KeyVault:Uri"];if (string.IsNullOrWhiteSpace(keyVaultUri) is false){ builder.Configuration.AddAzureKeyVault( new Uri(keyVaultUri), new ManagedIdentityCredential(ManagedIdentityId.SystemAssigned), new AzureKeyVaultConfigurationOptions { ReloadInterval = TimeSpan.FromHours(12) });}Two details in that block carry most of the security argument:
ManagedIdentityCredential, notDefaultAzureCredential. The managed identity is the only credential this application should use.DefaultAzureCredentialwalks a chain of fallbacks — environment variables, workload identity, then developer-tool logins such as the Azure CLI’s — and a stray credential on the box would authenticate as a different, broader identity, one nobody expects to see in the vault’s audit log.- The
KeyVault:Uriguard. Only the production settings file sets it, so a developer machine never reaches for the production vault; locally the same keys live in .NET user-secrets. The flip side is that any host receiving the production build without vault access fails at startup, which is why the vault role grant comes before the first deploy.
Secret naming. Key Vault names allow only alphanumerics and hyphens, so the
configuration-key separator : is written as a double hyphen and the provider
translates it back: Cloudflare:ApiToken is stored as Cloudflare--ApiToken,
Umbraco:CMS:Global:Smtp:Password as Umbraco--CMS--Global--Smtp--Password.
Only actual secrets go in the vault — identifiers such as the Cloudflare
account ID, the map’s default location and the media container name are plain
configuration and live in the appsettings files.
Operationally. A rotated value reaches a running application within the
12-hour reload interval, or immediately on systemctl restart. The vault is a
dependency in the boot path: if it is unreachable at startup, the application
does not start. That is the right trade — better a hard failure than Umbraco
booting with no SMTP password.
Patching
Section titled “Patching”unattended-upgrades is enabled and limited to the distribution and security
pockets. Automatic reboot is off by design, so kernel and libc updates sit
staged until someone reboots. The manual routine:
sudo apt updatesudo apt-get upgrade -o APT::Get::Only-Source=securitycat /var/run/reboot-required && sudo rebootLogging
Section titled “Logging”| Application | umbraco/Logs/UmbracoTraceLog.*.json, and the backoffice log viewer |
| Service lifecycle | journalctl -u nri-inc |
| Reverse proxy | journalctl -u caddy |
| SSH | journalctl -u ssh |
| Backups | journalctl -u nri-inc-backup.service |
All of it stays on the box, and nothing ships it elsewhere. Azure Monitor
alerts on the VM’s availability and resource metrics (see
Monitoring), but nothing alerts on
nri-inc.service crashing, a failed backup, or the disk filling. A systemd OnFailure= hook on the two units that matter
would close the most important part of that gap cheaply.
Media and blob storage
Section titled “Media and blob storage”Media is not on the VM. It lives in Azure Blob Storage, in the media storage
account and the container named by
Umbraco:Storage:AzureBlob:Media:ContainerName.
One setting pair drives four consumers
Section titled “One setting pair drives four consumers”This is the thing to know before touching any of it. A single connection string
and container name — Umbraco:Storage:AzureBlob:Media:ConnectionString and
:ContainerName — govern four separate subsystems, which is why the
container has four top-level prefixes:
| Prefix | Written by | Breaks if wrong |
|---|---|---|
media/ |
AddAzureBlobMediaFileSystem() |
All site images and documents |
cache/ |
AddAzureBlobImageSharpCache() — no separate config, it reuses the Media settings |
Every resized or cropped image |
datakeys/ |
Umbraco.Community.DataProtection via Features/DataProtectionComposer.cs |
The ASP.NET DataProtection key ring |
website-content/ |
Features/AzureAiSearch/AzureStorageUploader.cs, reading the same two keys directly |
The AI search content upload |
Development and production share the account but not the container:
production uses the live container, development a separate staging one seeded
from it. The container name is in appsettings.Development.json; the
connection string is in .NET user-secrets, not the repository. Both must name
the same account, so change them together.
The credential is a storage account key, carried in the connection string held in Key Vault. Versioning is off on the account, so an overwritten blob is not recoverable, only a deleted one.
Changing the account or container
Section titled “Changing the account or container”Count both sides first, and only switch when every prefix matches exactly:
for p in cache datakeys media website-content; do az storage blob list -c <container> --prefix "$p/" --num-results "*" \ --query "[].properties.contentLength" -o tsv \ | awk -v P="$p" '{n++; s+=$1} END {printf "%-16s %6d blobs %14d bytes\n", P, n, s}'doneThen set the connection string in the key vault and the container name in the production settings file, and restart — both are read at startup, so the vault’s reload interval does not help. The vault keeps every prior version of a secret, so the previous connection string is the rollback.
Verifying a media switch
Section titled “Verifying a media switch”Reads are the easy half. Force a write, or you have proved only half of it:
# a size never requested before, so ImageSharp must WRITE a new cache blobcurl -s -o /dev/null -w "novel size: %{http_code}\n" -H 'Host: cms.nri-inc.org' \ "http://127.0.0.1:5019/media/<path>?width=321&height=200&rmode=crop"Then confirm the cache/ blob count in the new container went up, with
current timestamps. A 200 on its own would also be returned by a cached
response from the old account, so the count is the real check. Finish with a
Cloudflare purge for the hostname and re-verify publicly, including a resized
URL.
Backups
Section titled “Backups”Both SQLite databases are snapshotted daily at 00:00 UTC to the backup storage account. The account, its network rules, soft delete and lifecycle policy are on the Azure page.
flowchart LR T[systemd timer<br/>00:00 UTC] --> S[VACUUM INTO<br/>+ PRAGMA quick_check] S --> D1[www/daily/umbraco/<br/>deleted at 14 days] S --> D2[www/daily/automate/<br/>deleted at 30 days] S -->|first successful run<br/>of the month only| M[www/monthly/umbraco/<br/>deleted at 185 days] subgraph rg-nri-backup · RA-GRS · default-deny + vnet rule D1 D2 M end D1 & D2 & M --> SD[soft-deleted<br/>recoverable 30 more days] SD --> P[purged]Snapshots are taken with VACUUM INTO while Umbraco runs, checked with
PRAGMA quick_check, and uploaded under three paths:
| Path | Kept | Blob name |
|---|---|---|
daily/umbraco/ |
14 days | <yyyymmdd>-nri.Umbraco.sqlite.db |
daily/automate/ |
30 days | <yyyymmdd>-nri.Umbraco.Automate.sqlite.db |
monthly/umbraco/ |
185 days | <yyyymm>-nri.Umbraco.sqlite.db |
The paths exist because a lifecycle rule filters by prefix and can only include, never exclude, so each set that expires on its own schedule needs its own path. The retention works out to 14 daily and 6–7 monthly copies of the main database, and 30 daily copies of Automate.
The monthly copy is the main database only, and it is the same snapshot the
daily upload just took. Every run of the month attempts it; all but the first
find the blob already there, so the month’s copy is the first successful run of
that month, with no date arithmetic, and it self-heals if the 1st is missed.
Because the timer fires at 00:00 UTC, 202611-nri.Umbraco.sqlite.db is
October’s closing state. An existing blob is never overwritten, which makes a
same-day re-run harmless, and a non-blocking flock prevents overlapping runs.
sudo systemctl start nri-inc-backup.service # safe any timesudo systemctl show nri-inc-backup.service --property=Result --property=ExecMainStatussudo journalctl -u nri-inc-backup.service -n 50 --no-pagersystemctl list-timers --all 'nri-inc-backup*' --no-pager --fullSuccess is Result=success and ExecMainStatus=0, with two
Verified snapshot lines, two daily/ upload lines, and a monthly/ line
reading either Uploaded backup or Backup already exists. The log must never
contain the storage key.
Current limits
Section titled “Current limits”- Restores are not tested. Until one is, the backups are unproven in the
only way that counts. To test: download both blobs, run
PRAGMA integrity_check;on each, and boot a throwaway Umbraco against the main database. Never restore over the live databases whilenri-inc.serviceis running. - Nothing alerts on failure. A failed backup writes to the journal and nowhere else.
- The monthly set is 6 or 7 copies, not exactly 6. Deletion is age-based, so how many survive depends on the day of the month. Capping it at exactly six would need the job to count and prune, which is not worth the code.
- This job does not cover the backup environment file. See Data.
Deploying
Section titled “Deploying”From the repository root, with the SSH key loaded into the agent (see Where the private key is kept):
make deployThat one command does the whole release (Makefile):
- Builds the client bundles —
npm run build(browser client intowwwroot/client) andnpm run build:ssr(SSR tree intoSsr/) insrc/NRI.CMS/Client. - Publishes —
dotnet publish -c Release -r linux-x64 --no-self-contained /p:UseAppHost=false. - Pushes the publish output to
/var/www/nri-inc.org/withrsync --delete, writing files aswww-data. The rsync excludes/umbraco/, so databases, logs and indexes are never touched. - Restarts
nri-inc.serviceand prints its status.
REMOTE_HOST defaults to the VM’s ~/.ssh/config entry, so no key file and no
address appear on the command line. The site returns 502 for a few seconds
after the restart while Umbraco boots.
Releases run from an operator’s machine and depend on that machine holding the SSH key. A build host or CI job would remove that dependency.
Cloudflare cache purge
Section titled “Cloudflare cache purge”Cloudflare:ApiToken is an API token owned by the NRI Cloudflare account,
limited to the nri-inc.org zone with Zone Read and Cache Purge. The CMS uses
it to purge {url}* when a page is published or media is saved
(Features/Cloudflare): everything whose address starts with the item’s URL —
with and without the trailing slash, query string variants such as image
crops, and descendant pages. A site root is purged as its one exact URL, since
its prefix would be the whole site. Pages elsewhere that only reference the
item are not purged. It only runs when Cloudflare:PurgeOnPublish is true,
which is set in appsettings.Production.json.
Each purge writes a line to the Umbraco log — Purged <url>* from the Cloudflare cache, or a Cloudflare cache purge failed warning — visible in
the backoffice under Settings → Log Viewer and in
umbraco/Logs/UmbracoTraceLog.*.json on the server. make cloudflare-purge
purges the whole cms.nri-inc.org hostname from an operator’s machine, using
a token read from the macOS Keychain.