Li
Networking Azure

LibreSpeed on Ubuntu 24.04 on Azure User Guide

| Product: LibreSpeed on Ubuntu 24.04 on Azure

Overview

This image runs LibreSpeed 6.3.1 on Ubuntu 24.04 LTS. LibreSpeed is an open source speed test that you host yourself and run in any modern browser. It measures download and upload throughput, ping and jitter between the browser and your own server, with no Flash, Java or WebSocket and no third party service in the path. Use it to test the link to an Azure region, a VPN or WireGuard tunnel, a site to site connection or a branch office.

The image holds the official LibreSpeed 6.3.1 release, served by Apache 2.4 with PHP 8.3, both from Ubuntu's own archive, so Ubuntu's unattended security upgrades patch them along with the rest of the system. It is laid out the way LibreSpeed's own container image lays out a standalone server: one test server (this virtual machine), results sharing on, and every finished test stored in a local SQLite database that you look up on a password protected results page.

The results page password, the key that obfuscates test IDs and the TLS certificate are created on the first boot of every virtual machine and never shared with another one. No default password ever works. The password is written to /root/librespeed-credentials.txt, readable by root only.

The image is set up as follows:

  • The speed test is served on port 80 and over HTTPS on port 443. The results page is served over HTTPS only: on port 80 it redirects to HTTPS.
  • Results are stored in /var/lib/librespeed/speedtest_telemetry.db, outside the web root.
  • The ISP shown next to a visitor's address comes from the offline database LibreSpeed ships; the server never calls an outside service to look it up.
  • Ubuntu's unattended security upgrades are switched on.

The default operating system user is the administrator account you choose when you create the virtual machine (azureuser in the examples below). LibreSpeed's files are in /var/www/librespeed.

Prerequisites

  • A Microsoft Azure subscription in which you can create resource groups, virtual networks and virtual machines
  • An SSH key pair for the administrator account
  • The Azure CLI (az) if you deploy from the command line

The recommended size is Standard_B2s (2 vCPUs, 4 GiB memory). A speed test can only measure up to the network bandwidth of the virtual machine size, so choose a larger size, with accelerated networking, to test links faster than a few hundred megabits per second.

Step 1: Deploy the Virtual Machine

Option A: the Azure Portal

  1. Sign in to the Azure Portal, open Marketplace, search for LibreSpeed on Ubuntu 24.04 by cloudimg and select Create.
  2. On Basics choose your subscription, a resource group, a region and a name, and pick Standard_B2s or larger. Under Administrator account choose SSH public key and enter your user name and key.
  3. Under Inbound port rules allow SSH (22), HTTP (80) and HTTPS (443). After the virtual machine is created, narrow the SSH rule on its network security group to your own network.
  4. Select Review + create, then Create.

First boot finishes within a minute of the virtual machine showing Running.

Option B: the Azure CLI

Accept the Marketplace terms once per subscription, then create the virtual machine. Replace <your-mgmt-cidr> with the network you manage it from, for example 203.0.113.0/24, and <your-test-cidr> with the networks whose people run tests (or * for anyone):

az vm image terms accept --urn cloudimg1647283583153:librespeed:default:latest

RG=librespeed-rg
az group create --name $RG --location eastus
az vm create \
  --resource-group $RG \
  --name librespeed-01 \
  --image cloudimg1647283583153:librespeed:default:latest \
  --size Standard_B2s \
  --admin-username azureuser \
  --ssh-key-values ~/.ssh/id_rsa.pub \
  --public-ip-sku Standard \
  --nsg-rule NONE
az network nsg rule create --resource-group $RG --nsg-name librespeed-01NSG \
  --name AllowSsh --priority 1000 --access Allow --protocol Tcp \
  --direction Inbound --source-address-prefixes <your-mgmt-cidr> --destination-port-ranges 22
az network nsg rule create --resource-group $RG --nsg-name librespeed-01NSG \
  --name AllowSpeedTest --priority 1010 --access Allow --protocol Tcp \
  --direction Inbound --source-address-prefixes <your-test-cidr> --destination-port-ranges 80 443

Step 2: Connect to the Virtual Machine

Find the public IP address, then connect over SSH:

az vm show --resource-group librespeed-rg --name librespeed-01 --show-details --query publicIps -o tsv
ssh azureuser@<public-ip>

The message of the day shows the speed test address, the results page and where the password is:

  LibreSpeed 6.3.1 on Ubuntu 24.04 (cloudimg)
  Speed test:        http://203.0.113.10/  (and https://)
  Results page:      https://203.0.113.10/results/stats.php
  Stats password:    sudo cat /root/librespeed-credentials.txt
  Change address:    sudo cloudimg-set-public-address <ip-or-dns-name>
  User guide:        https://www.cloudimg.co.uk/guides/librespeed-on-ubuntu-24-04-azure/

Check that Apache and first boot are active, the versions, and that the server answers:

systemctl is-active apache2 librespeed-firstboot
grep -m1 '^> Version' /usr/share/doc/librespeed/doc.md
apache2 -v | head -1
php -v | head -1
curl -ks -o /dev/null -w 'https://127.0.0.1/healthz -> %{http_code}\n' https://127.0.0.1/healthz
active
active
> Version 6.3.1
Server version: Apache/2.4.58 (Ubuntu)
PHP 8.3.6 (cli) (built: Nov 18 2026 23:42:07) (NTS)
https://127.0.0.1/healthz -> 200

Apache and first boot active, the LibreSpeed, Apache and PHP versions, and the health check on a new VM

Step 3: Read the Results Page Password

sudo cat /root/librespeed-credentials.txt

The file holds the speed test and results page addresses and the results page password created for this virtual machine:

# LibreSpeed 6.3.1 - generated on first boot by librespeed-firstboot.service. Unique to this VM; store it safely.
LIBRESPEED_URL=http://203.0.113.10/
LIBRESPEED_HTTPS_URL=https://203.0.113.10/
LIBRESPEED_STATS_URL=https://203.0.113.10/results/stats.php
LIBRESPEED_STATS_PASSWORD=************************

# Run a test at LIBRESPEED_URL (or LIBRESPEED_HTTPS_URL). Every finished test is stored in
# /var/lib/librespeed/speedtest_telemetry.db; sign in to LIBRESPEED_STATS_URL with the password above to look them up.
# The certificate is self-signed and made for this VM: your browser warns until you install your own.
# Use your own DNS name or another address:  sudo cloudimg-set-public-address speedtest.example.com
# Set the privacy policy's contact address:  sudo librespeed-set-privacy-contact you@example.com
# User guide: https://www.cloudimg.co.uk/guides/librespeed-on-ubuntu-24-04-azure/

Store the password in a password manager. The password also sits in LibreSpeed's settings file, /var/www/librespeed/results/telemetry_settings.php, which only root and the web server can read. If Azure did not report a public IP address when the virtual machine first booted (for example, a virtual machine with only a private address), the addresses in the file use the private address instead.

The per VM credentials file and its permissions

Step 4: Run a Speed Test

Open http://<public-ip>/ in your browser (or https://<public-ip>/: the certificate is a self-signed one made for this virtual machine, so the browser warns once). The page opens LibreSpeed's classic design with this virtual machine as the test server. Select Start.

LibreSpeed's speed test page served from the VM, ready to start

The test measures download, upload, ping and jitter in turn. When it finishes, the page shows a Test ID, a link to share the result and the result as an image:

A finished test: download, upload, ping and jitter measured against the VM, with its test ID and result image

The figures are the capacity of the path between the browser and the virtual machine: your own connection, the internet or private link in between, and the virtual machine's own network limit. Run the test from each end of the link you want to measure, for example from an office, through a VPN, or from another virtual machine in a peered network.

From the command line, LibreSpeed's address check answers with the address the server sees:

curl -s http://127.0.0.1/backend/getIP.php?isp=true; echo
{"processedString":"127.0.0.1 - localhost IPv4 access","rawIspInfo":""}

Step 5: Look Up Results on the Results Page

Open https://<public-ip>/results/stats.php. The results page is served over HTTPS only; the same address on port 80 redirects to it.

The results page sign in, over HTTPS

Sign in with the password from step 3. The page lists the last 100 tests, or the test whose ID you enter, with the visitor's address and ISP, browser, speeds, ping and jitter:

A stored test on the signed in results page

Test IDs are obfuscated with a key made on this virtual machine, so nobody can guess the address of another person's result. The image's own check proves the password works end to end: the password from the credentials file signs in, LibreSpeed's placeholder password and a blank one are refused, and a test result is stored, listed and drawn as an image, then deleted again:

sudo bash /usr/local/sbin/librespeed-cred-roundtrip.sh
sudo ls -l /var/lib/librespeed/
LIBRESPEED_ROUNDTRIP_OK
total 12
-rw-r--r-- 1 www-data www-data 12288 Dec  1 09:54 speedtest_telemetry.db

The address check, the results page sign in check and the results database

To change the results page password, put a new one of 16 to 64 letters and digits in the settings file. The command reads it from your keyboard, so it never appears in your shell history:

# at the prompt type <new-password>: 16 to 64 letters and digits
read -rs -p 'New results page password: ' P; echo
printf '%s\n' "$P" | sudo php /usr/local/lib/cloudimg/librespeed-setpass.php /var/www/librespeed/results/telemetry_settings.php && unset P

Then update LIBRESPEED_STATS_PASSWORD in /root/librespeed-credentials.txt so it stays the record of the current password.

Step 6: Choose the Classic or Modern Design

LibreSpeed has two designs. The classic design is the default. To try the modern one, add ?design=new to the address (http://<public-ip>/?design=new); ?design=classic goes back. The default for every visitor is set by useNewDesign in /var/www/librespeed/config.json:

cat /var/www/librespeed/config.json
{
  "useNewDesign": false
}

To make the modern design the default, change false to true in that file and save it. The change takes effect on the next page load:

sudo nano /var/www/librespeed/config.json

The test settings, such as how long the download and upload phases run, are in /var/www/librespeed/settings.json. Leave telemetry_level at basic: it is what stores each result for the results page.

Step 7: Set the Privacy Policy Contact

Every stored result holds the visitor's IP address, ISP and browser. LibreSpeed's privacy policy page (the Privacy link under the start button) tells visitors this and gives an address for deletion requests. Set that address to your own:

sudo librespeed-set-privacy-contact <your-email>

sudo librespeed-set-privacy-contact --reset puts LibreSpeed's placeholder back. To delete one visitor's results, sign in to the results page, note the test IDs, and remove the rows from the database (step 10 shows where it is).

Step 8: Use Your Own Domain and Certificate

Point a DNS name, such as speedtest.example.com, at the virtual machine's public IP, then tell the image to use it. This rewrites the credentials file and makes a new self-signed certificate for the name:

sudo cloudimg-set-public-address <your-domain>

To use a certificate from a certificate authority instead, copy your certificate chain and its private key over the two files Apache uses, then reload Apache:

sudo install -m 644 -o root -g root fullchain.pem /etc/ssl/librespeed/librespeed.crt
sudo install -m 600 -o root -g root privkey.pem /etc/ssl/librespeed/librespeed.key
sudo apache2ctl -t && sudo systemctl reload apache2

cloudimg-set-public-address makes a new self-signed certificate each time it runs, so run it before you install your own certificate, or install yours again afterwards.

Step 9: Behind a Reverse Proxy or Load Balancer

LibreSpeed records the address of whoever connects. Apache on this image removes the X-Forwarded-For, X-Real-IP, Client-IP and CF-Connecting-IPv6 headers from every request, so a visitor cannot make the server record an address of their choosing:

curl -s -H 'X-Forwarded-For: 203.0.113.9' http://127.0.0.1/backend/getIP.php; echo
{"processedString":"127.0.0.1","rawIspInfo":""}

If you put the speed test behind your own reverse proxy or Azure Application Gateway, every result shows the proxy's address. To record the visitors' real addresses, enable Apache's remoteip module and trust only your proxy's address for the forwarded header, in a file such as /etc/apache2/conf-available/remoteip.conf with RemoteIPHeader X-Forwarded-For and RemoteIPInternalProxy <proxy-ip>. Note that a proxy in the path also limits the speeds the test can measure.

Step 10: Back Up and Upgrade

The results are in the SQLite database /var/lib/librespeed/speedtest_telemetry.db, and the settings in /var/www/librespeed. Back up both while Apache is stopped, so the database copy is consistent. Replace <backup-dir> with a folder on another disk or a mounted share:

sudo systemctl stop apache2
sudo cp -a /var/lib/librespeed/speedtest_telemetry.db <backup-dir>/
sudo tar -czf <backup-dir>/librespeed-www-$(date +%F).tar.gz -C /var/www librespeed
sudo systemctl start apache2

Ubuntu's unattended upgrades keep Ubuntu, Apache and PHP patched. LibreSpeed itself is a set of web files: to move to a new release, read its release notes at https://github.com/librespeed/speedtest/releases, back up first, and copy the new release's files over /var/www/librespeed, keeping your results/telemetry_settings.php, results/idObfuscation_salt.php, config.json, settings.json and server-list.json.

Server Components

Component Version Notes
LibreSpeed 6.3.1 The official release, in /var/www/librespeed; classic and modern designs
Apache HTTP Server 2.4.58 Ubuntu's apache2 package; the speed test on 80 and 443, the results page on 443 only
PHP 8.3.6 Ubuntu's libapache2-mod-php8.3, with the SQLite and GD modules
SQLite 3 The results database, through PHP's SQLite module
Ubuntu 24.04 LTS Azure kernel 6.8, unattended security upgrades on

Filesystem Layout

Mount Size What is there
/ 30 GB OS disk (29 GB root partition) Ubuntu, LibreSpeed in /var/www/librespeed, the results database in /var/lib/librespeed
/boot 881 MB Kernels
/boot/efi 105 MB EFI system partition
/mnt Azure temporary disk (size depends on the VM size) Scratch space only: Azure may wipe it on a stop, resize or redeploy. Never keep the database or backups here

Each stored result takes well under a kilobyte, so the root disk holds millions of results.

Managing the Services

sudo systemctl status apache2 --no-pager
sudo tail -n 20 /var/log/apache2/librespeed-access.log

Restart the web server with sudo systemctl restart apache2.

Scripts and Log Files

Path What it does
/var/www/librespeed LibreSpeed's web files: the two designs, backend/ (the test endpoints) and results/ (storing results, the results page and the result image)
/var/www/librespeed/results/telemetry_settings.php The results page password and the database settings (root and the web server only)
/var/www/librespeed/config.json Which design is the default
/var/www/librespeed/settings.json The test settings
/var/lib/librespeed/speedtest_telemetry.db The stored results
/etc/apache2/sites-available/librespeed.conf The Apache site: port 80 and 443
/etc/ssl/librespeed/ The TLS certificate and key
/root/librespeed-credentials.txt The addresses and the results page password (root only)
/usr/local/sbin/librespeed-firstboot.sh First boot: creates the password, the test ID key and the TLS certificate, then writes /var/lib/cloudimg/librespeed-firstboot.done
/usr/local/sbin/librespeed-cred-roundtrip.sh Checks that the password in the credentials file signs in, and that a result is stored and drawn (run with sudo)
/usr/local/sbin/librespeed-set-privacy-contact Sets the privacy policy's contact address
/var/log/apache2/librespeed-access.log Every request to the speed test
/var/log/apache2/librespeed-error.log Apache and PHP errors
/var/log/librespeed-firstboot.log The first boot log

On Startup

On the first boot librespeed-firstboot.service runs once: it replaces LibreSpeed's placeholder password with a password made on the virtual machine, writes the key that obfuscates test IDs, makes the TLS certificate for the virtual machine's address, writes the credentials file and records /var/lib/cloudimg/librespeed-firstboot.done. Apache does not start until first boot has finished, so the results page never runs without its own password. On every later boot Apache starts as a normal systemd service.

Troubleshooting

The credentials file is not there yet. First boot is still running. Wait a minute, then check systemctl status librespeed-firstboot --no-pager and sudo cat /var/log/librespeed-firstboot.log.

The browser cannot reach the speed test. Check that the network security group allows TCP 80 and 443 from your address (step 1), and that systemctl is-active apache2 reports active.

The results page says the password is wrong. Copy it again from sudo cat /root/librespeed-credentials.txt; it is case sensitive. If you changed it (step 5), the file holds what you wrote there.

The results page on port 80 jumps to HTTPS. That is by design: the password only ever crosses the network encrypted.

Speeds are lower than expected. The test measures the whole path, including the virtual machine size's network limit. Try a larger size with accelerated networking, and test from a wired connection.

The browser warns about the certificate. The certificate is self-signed for this virtual machine. Install your own (step 8).

Security Recommendations

The virtual machine listens on SSH (22), the speed test (80) and the speed test and results page over HTTPS (443). The results page refuses port 80 and redirects to HTTPS, Apache does not say its version, the forwarded address headers a visitor sends are dropped, and Apache and PHP cannot reach the Azure instance metadata service (169.254.169.254) or the Azure host endpoint (168.63.129.16):

sudo ss -lntH | awk '{print $4}' | grep -vE '^127\.|%lo:' | sort -u
curl -s -o /dev/null -w 'http://127.0.0.1/results/stats.php -> %{http_code} %{redirect_url}\n' http://127.0.0.1/results/stats.php
curl -sI http://127.0.0.1/ | grep -i '^server:'
systemctl show -p IPAddressDeny --value apache2
*:443
*:80
0.0.0.0:22
[::]:22
http://127.0.0.1/results/stats.php -> 301 https://127.0.0.1/results/stats.php
Server: Apache
169.254.169.254/32 168.63.129.16/32 ::ffff:168.63.129.16/128 ::ffff:169.254.169.254/128

Listening ports, the results page HTTPS redirect, the server header and the metadata block

  • Open SSH only to your own network.
  • Open 80 and 443 only to the people who run tests, unless the speed test is meant to be public.
  • Keep the results page password safe, and change it if it may have been seen (step 5).
  • Install your own certificate for the results page (step 8).
  • Leave unattended upgrades on.

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. For LibreSpeed itself, see the project's documentation at https://github.com/librespeed/speedtest.

LibreSpeed is licensed under the GNU Lesser General Public License v3. All product and company names are trademarks or registered trademarks of their respective holders. Use of them does not imply any affiliation with or endorsement by them.