Developer Tools Azure

Node.js 26 LTS on Ubuntu 26.04 on Azure User Guide

| Product: Node.js 26 LTS on Ubuntu 26.04 LTS on Azure

Overview

Node.js is the open source JavaScript runtime built on Google's V8 engine, used to run web servers, REST and GraphQL APIs, real time services over WebSockets, server side rendering and build tooling. Node.js 26 is the current long term support (LTS) line. The cloudimg image delivers Node.js 26 LTS with npm and pnpm on Ubuntu 26.04 LTS, and a small Express 5 sample app already running under systemd behind nginx over HTTPS, so a fresh VM answers on https://<vm-public-ip>/ the moment it boots and you have a working pattern to drop your own app into. cloudimg's support team is on hand 24 hours a day by email (support@cloudimg.co.uk), with a guaranteed response within 24 hours.

Node.js is distributed under the MIT License (/usr/share/doc/nodejs/copyright on the image), npm under the Artistic License 2.0 and pnpm under the MIT License. cloudimg is not affiliated with, endorsed by, or sponsored by the OpenJS Foundation or the Node.js project. This image repackages the upstream releases with cloudimg's provisioning and support.

What is included:

  • Node.js 26 LTS (26.14.0 at build time) with npm and npx, from NodeSource's signed apt repository, so apt and Ubuntu's unattended upgrades keep it on the newest 26.x release
  • pnpm 12, installed globally
  • A sample Express 5 app in /opt/nodeapp/app, run by nodeapp.service as the unprivileged nodeapp account on 127.0.0.1:3000 only, restarted by systemd if it fails and started at boot
  • nginx in front of it: HTTPS on :443 (HTTP/2, TLS 1.2 and 1.3, WebSocket upgrades passed through), with :80 redirecting to HTTPS and answering a plain /health check
  • A per-VM TLS certificate and a per-VM admin API key for the sample's protected route, both made on first boot. The key goes to the root-only file /root/nodejs-credentials.txt. No default or shared secret ships in the image
  • cloudimg's support team on hand 24 hours a day by email (support@cloudimg.co.uk), with a guaranteed response within 24 hours

Node.js, npm, npx and pnpm versions

Prerequisites

An active Azure subscription, an SSH key pair, and a VNet plus subnet in the target region. Standard_B2s (2 vCPU / 4 GiB RAM) is a good starting point for an API or web app; choose a larger size for heavier traffic or for builds. NSG inbound: allow 22/tcp from your management network and 443/tcp (HTTPS) plus 80/tcp (which redirects to HTTPS) from your users.

Step 1 — Deploy from the Azure Marketplace

Sign in to the Azure Portal, choose Create a resource, search the Marketplace for Node.js 26 LTS by cloudimg, and select Create. On Basics pick your subscription, resource group, region and size; under Administrator account choose SSH public key and paste your key; under Inbound port rules allow SSH (22), HTTP (80) and HTTPS (443). Then Review + create and Create.

Step 2 — Deploy from the Azure CLI

# Accept the Marketplace terms once per subscription (required before the first CLI deploy)
az vm image terms accept --urn cloudimg1647283583153:nodejs-ubuntu-26-04:default:latest

az vm create \
  --resource-group <your-rg> \
  --name nodejs \
  --image cloudimg1647283583153:nodejs-ubuntu-26-04:default:latest \
  --size Standard_B2s \
  --admin-username azureuser \
  --generate-ssh-keys \
  --public-ip-sku Standard

Open HTTPS (and HTTP, which redirects) to reach the app:

az vm open-port --resource-group <your-rg> --name nodejs --port 443 --priority 900
az vm open-port --resource-group <your-rg> --name nodejs --port 80  --priority 910

Step 3 — Connect to your VM

ssh azureuser@<vm-public-ip>

The address is on the VM's Overview page in the portal, or from the CLI with az vm show -d -g <your-rg> -n nodejs --query publicIps -o tsv.

Step 4 — Confirm the services are running

First boot, the app and nginx should all report active. Plain HTTP answers the /health check and redirects everything else to HTTPS, and the app answers its health check through nginx over TLS, checked against the VM's own certificate. The app (3000) listens on loopback only; only nginx faces the network:

systemctl is-active nodejs-firstboot nodeapp nginx
curl -s -o /dev/null -w 'health         -> %{http_code}\n' http://127.0.0.1/health
curl -s -o /dev/null -w 'http redirect  -> %{http_code} %{redirect_url}\n' http://127.0.0.1/
curl -s --cacert /etc/nginx/ssl/nodejs.crt -w '  <- https healthz\n' https://127.0.0.1/healthz
sudo ss -tln | grep -E ':(80|443|3000) ' | awk '{print $4}'

Expected output:

active
active
active
health         -> 200
http redirect  -> 301 https://127.0.0.1/
ok
  <- https healthz
0.0.0.0:443
0.0.0.0:80
127.0.0.1:3000
[::]:443
[::]:80

The app and nginx under systemd, and their listeners

Step 5 — Check the runtime

Node.js comes from NodeSource's repository for the 26.x line, which apt keeps current:

node --version
npm --version
pnpm --version
dpkg-query -W -f '${Package} ${Version}\n' nodejs
grep -E '^(URIs|Suites)' /etc/apt/sources.list.d/nodesource.sources

Expected output (the versions are those at build time; apt moves them forward within 26.x):

v26.14.0
11.21.3
12.25.1
nodejs 26.14.0-1nodesource1
URIs: https://deb.nodesource.com/node_26.x
Suites: nodistro

Step 6 — Retrieve your admin API key

On the first boot of every VM, nodejs-firstboot.service makes an admin API key unique to that VM (64 hexadecimal characters), writes it to the app's environment file, records the VM's address and writes the details to a root-only file. nginx makes the VM's own self-signed certificate before it first starts. No shared or default secret ships in the image, and the sample app refuses to start without a key.

sudo cat /root/nodejs-credentials.txt

The file (mode 0600, root only) holds the app's URL, the key and the certificate's path:

# Node.js 26 LTS on Ubuntu 26.04 LTS - made on this VM's first boot by nodejs-firstboot.service.
# This key is unique to this VM. Store it somewhere safe.

APP_URL=https://<VM address>/
ADMIN_API_KEY=<ADMIN_API_KEY>
TLS_CERTIFICATE=/etc/nginx/ssl/nodejs.crt

# The sample app answers at https://<VM address>/ (port 80 redirects there). The certificate is this VM's own,
# self-signed, so a browser warns once. The key protects the sample's /api/admin route:
#   curl --cacert nodejs.crt -H "X-Admin-Key: <the key above>" https://<VM address>/api/admin
# The app reads the key from /etc/nodeapp/nodeapp.env. Guide:
# https://www.cloudimg.co.uk/guides/nodejs-26-on-ubuntu-26-04-azure/

The app reads its settings from /etc/nodeapp/nodeapp.env (mode 0640, root:nodeapp), so the key never appears on a command line or in the unit file:

sudo grep -v '^ADMIN_API_KEY=' /etc/nodeapp/nodeapp.env

Expected output:

# Node.js sample app environment (cloudimg). nodeapp.service reads this file; restart it after a change:
#   sudo systemctl restart nodeapp
NODE_ENV=production
HOST=127.0.0.1
PORT=3000
# This VM's admin API key, made on first boot (also in /root/nodejs-credentials.txt).

Step 7 — Call the sample app over HTTPS

The sample app has a page at /, the runtime as JSON at /api/info, a health check at /healthz, and /api/admin, a route that needs this VM's key in the X-Admin-Key header. From the VM's own shell, checked against the VM's certificate:

curl -s --cacert /etc/nginx/ssl/nodejs.crt https://127.0.0.1/api/info | jq .

Expected output:

{
  "app": "cloudimg-nodeapp",
  "node": "v26.14.0",
  "v8": "14.6.202.34-node.58",
  "openssl": "3.5.9",
  "platform": "linux/x64",
  "uptimeSeconds": 113
}

HTTPS with the VM's certificate, the redirect and /api/info

The protected route refuses a request with no key and one with a wrong key (401), and answers this VM's key (200). The key is read from the credentials file into a variable, never typed:

KEY=$(sudo sed -n 's/^ADMIN_API_KEY=//p' /root/nodejs-credentials.txt)
curl -s --cacert /etc/nginx/ssl/nodejs.crt -o /dev/null -w 'no key    -> %{http_code}\n' https://127.0.0.1/api/admin
curl -s --cacert /etc/nginx/ssl/nodejs.crt -o /dev/null -w 'wrong key -> %{http_code}\n' -H 'X-Admin-Key: not-the-key' https://127.0.0.1/api/admin
curl -s --cacert /etc/nginx/ssl/nodejs.crt -o /dev/null -w 'right key -> %{http_code}\n' -H "X-Admin-Key: $KEY" https://127.0.0.1/api/admin
unset KEY

Expected output:

no key    -> 401
wrong key -> 401
right key -> 200

The admin route: no key and a wrong key refused, this VM's key answered

In a browser, go to https://<vm-public-ip>/. The certificate is the VM's own self-signed one, so the browser warns once: continue past it, or install your own certificate (see Your own domain and certificate). The page reads Node.js 26 LTS is running and links to the routes above.

To call the API from your own computer with the certificate checked, copy it down and pass it to curl:

scp azureuser@<vm-public-ip>:/etc/nginx/ssl/nodejs.crt .
curl --cacert nodejs.crt https://<vm-public-ip>/api/info

Step 8 — Install packages with npm and pnpm

npm and pnpm install from the public npm registry. This makes a throwaway project, installs Express with npm and a small package with pnpm, then deletes the project:

cd "$(mktemp -d)" && npm init -y >/dev/null && npm install --no-fund --no-audit express@5 2>&1 | tail -1
node -e "console.log('express', require('express/package.json').version)"
pnpm add --silent is-number@7.0.0 >/dev/null 2>&1; ls
P=$PWD; cd / && rm -rf "$P"

Expected output:

added 65 packages in 2s
express 5.3.0
node_modules
package-lock.json
package.json
pnpm-lock.yaml

Deploying your own app

The sample shows the pattern to keep: your app listens on 127.0.0.1:3000, systemd runs it as the unprivileged nodeapp account with its settings from /etc/nodeapp/nodeapp.env, and nginx serves it over HTTPS. The quickest route is to put your app in place of the sample:

sudo systemctl stop nodeapp
sudo mv /opt/nodeapp/app /opt/nodeapp/sample
sudo git clone https://github.com/<you>/<your-app>.git /opt/nodeapp/app
sudo chown -R nodeapp:nodeapp /opt/nodeapp/app
cd /opt/nodeapp/app && sudo -u nodeapp -H npm ci --omit=dev

If your entry point is not server.js, point the unit at it with a drop-in (sudo systemctl edit nodeapp), which survives image updates:

[Service]
ExecStart=
ExecStart=/usr/bin/node /opt/nodeapp/app/dist/index.js
# Give the app somewhere to write, if it needs it (the unit is ProtectSystem=strict). Each path
# must exist, owned by nodeapp, or the unit will not start:
ReadWritePaths=/var/lib/nodeapp /opt/nodeapp/app/uploads

Add your own settings (database URLs, API keys) to /etc/nodeapp/nodeapp.env; your app reads them from process.env. Your app must listen on the HOST and PORT there (127.0.0.1 and 3000), or change PORT and the server 127.0.0.1:3000; line in /etc/nginx/sites-available/cloudimg-nodeapp together. Then start it and follow its log:

sudo systemctl daemon-reload
sudo systemctl restart nodeapp
journalctl -u nodeapp -f

ADMIN_API_KEY is only used by the sample app. The sample checks it is a 64 character key before it starts; your own app is free to ignore it or use it the same way.

Server components

Component Version at build Source
Node.js (with npm and npx) 26.14.0 (npm 11.21.3) NodeSource apt repository node_26.x
pnpm 12.25.1 npm registry, installed globally
Express (sample app) 5.3.0 npm registry, in /opt/nodeapp/app/node_modules
nginx 1.28.3 Ubuntu 26.04 archive
Ubuntu 26.04 LTS patched at build time

Filesystem layout

Path What it holds
/opt/nodeapp/app The sample app (server.js, public/, package.json, node_modules/), owned by nodeapp
/etc/nodeapp/nodeapp.env The app's environment: NODE_ENV, HOST, PORT, ADMIN_API_KEY (0640 root:nodeapp)
/etc/systemd/system/nodeapp.service The app's unit
/var/lib/nodeapp The nodeapp account's home, the one place the app may write
/etc/nginx/sites-available/cloudimg-nodeapp nginx: :80 redirect and :443 proxy to the app
/etc/nginx/ssl/nodejs.crt, nodejs.key The VM's TLS certificate and key (key 0600 root)
/root/nodejs-credentials.txt This VM's URL and admin API key (0600 root)
/etc/apt/sources.list.d/nodesource.sources NodeSource's repository for Node.js 26.x

First-boot service and security model

nodejs-firstboot.service runs once, before nginx and the app, on the first boot of each VM: it makes the admin API key with openssl rand, writes it to /etc/nodeapp/nodeapp.env and /root/nodejs-credentials.txt, records the VM's public address and leaves the sentinel /var/lib/cloudimg/nodejs-firstboot.done so it never runs again. nginx runs /usr/local/sbin/nodejs-tls-cert before it starts, which makes a self-signed certificate for the VM's address only when none is there, so a certificate you install at the same paths is kept.

The app runs as nodeapp, which has no shell and no sudo, under systemd with NoNewPrivileges, ProtectSystem=strict, ProtectHome and PrivateTmp; it can write only to /var/lib/nodeapp unless you allow more. It listens on loopback only, so the network reaches it only through nginx. The sample sends no X-Powered-By header, and compares the admin key in constant time.

If the VM's public address changes, sudo cloudimg-set-public-address records the new one and remakes the self-signed certificate for it.

Managing the services

sudo systemctl status nodeapp nginx
sudo systemctl restart nodeapp          # after changing the app or /etc/nodeapp/nodeapp.env
sudo systemctl reload nginx             # after changing the nginx site (run sudo nginx -t first)
journalctl -u nodeapp -n 50 --no-pager  # the app's console output

Your own domain and certificate

Point a DNS record at the VM's public address, then get a free certificate from Let's Encrypt with certbot's nginx plugin, which edits the site and renews the certificate itself:

sudo apt-get install -y certbot python3-certbot-nginx
sudo certbot --nginx -d app.your-domain.com

Or copy a certificate you already have over /etc/nginx/ssl/nodejs.crt (full chain) and /etc/nginx/ssl/nodejs.key (mode 0600), then sudo systemctl reload nginx. Either way the image's certificate script leaves your certificate alone.

Keeping Node.js updated

Ubuntu's unattended upgrades are on, and the image adds NodeSource's repository to the origins they may install from (Ubuntu's default allows only its own), so Node.js 26.x security releases arrive with your other updates:

apt-config dump Unattended-Upgrade::Origins-Pattern

Expected output:

Unattended-Upgrade::Origins-Pattern "";
Unattended-Upgrade::Origins-Pattern:: "site=deb.nodesource.com";

The running app keeps the old runtime until it restarts, so restart it after an update (or let your maintenance window's reboot do it). To update now:

sudo apt-get update
sudo apt-get install --only-upgrade nodejs
sudo systemctl restart nodeapp

To update pnpm: sudo npm install -g pnpm@12. Your app's own dependencies are yours to update (npm outdated, npm update, npm audit).

Troubleshooting

  • The browser shows a certificate warning. Expected with the VM's self-signed certificate; install your own (above).
  • 502 Bad Gateway. The app is not answering on 127.0.0.1:3000: sudo systemctl status nodeapp and journalctl -u nodeapp -n 50.
  • The app exits with status 78 and "refusing to start". ADMIN_API_KEY in /etc/nodeapp/nodeapp.env is empty or not 64 hexadecimal characters; first boot writes it, so check journalctl -u nodejs-firstboot.
  • Your app cannot write a file (EROFS or EACCES). Add the directory to ReadWritePaths= in a drop-in and make it writable by nodeapp.
  • Nothing answers from outside. Check the NSG allows 443 and 80, and sudo nginx -t.

Security recommendations

  • Restrict 22/tcp in the NSG to your own network, and 443/80 to your users where you can.
  • Keep /root/nodejs-credentials.txt and /etc/nodeapp/nodeapp.env as they are (root only, and root plus nodeapp); put your app's secrets in the environment file, not in the code.
  • Keep your app on loopback behind nginx, and install a trusted certificate for a public service.
  • Leave unattended upgrades on, and run npm audit on your app's dependencies.

Support

cloudimg's support team is on hand 24 hours a day by email at support@cloudimg.co.uk, with a guaranteed response within 24 hours. Node.js itself is documented at nodejs.org/docs.