Guide

Build a small web server

Start with one page

This example builds a bootable x86_64 server image with nginx, a firewall, and key-only SSH. It serves a page on port 80. You can boot it in QEMU before giving it to a VM host.

Use another x86_64 Linux computer as the build host. A stock installed or live Vessel 2026.1 system doesn't carry this builder's complete offline inputs, and Vessel 2026.1 cannot run QEMU itself. Installing Sigil on another Linux computer isn't the whole setup either: this guide starts with an existing Vessel source build environment. The checkout's README.md and packages/vessel-efi/README.md describe its separate source bootstrap and firmware inputs. That preparation hasn't been qualified here from a fresh machine.

Work from a Vessel source checkout with its bootstrapped Sigil toolchain. You need the package build store and seed used by that checkout, Zig, QEMU with qemu-img, OVMF firmware, OpenSSH, and curl. Building the kernel and packages from an empty store takes much longer than assembling an image from cached packages. Use a build machine with room for both.

The qualified path assembled packages already admitted by identity and content with a cache-only package realizer and a previously built matching EFI selector, then booted and checked the image in QEMU. An ordinary empty-store package and toolchain build was not exercised.

The files live in docs/manual/examples/web-server/. The builder requires AUTHORIZED_KEY_FILE, pointing to your public SSH key. It refuses a private key, an armored block, a malformed key line, or a file without any public keys before creating output or store artifacts. Blank lines and comments are ignored; every other line is checked as a public key on its own. Keep its matching private key on the computer you'll connect from. The placeholder below exists so the manual can check the configuration without anyone's credentials; it doesn't grant access.

If QEMU will run on a different computer, build with that computer's public key. Copy only the public key to the build host; its matching private key stays on the QEMU host.

Example: small-web-server-system

(import (vessel system)
        (vessel system features networking)
        (vessel system features nginx)
        (vessel system features ssh)
        (vessel packages linux))

(define public-key
  ;; The builder supplies only the public-key lines it has validated.
  (or (getenv "WEB_SERVER_VALIDATED_PUBLIC_KEYS")
      (if (getenv "AUTHORIZED_KEY_FILE")
          (error "Use build.sgl to validate the public-key file")
          "ssh-ed25519 REPLACE-WITH-YOUR-PUBLIC-KEY\n")))

(system-configuration
  host-name: "harbor"
  kernel: linux
  kernel-parameters: '("console=ttyS0" "panic=-1")
  bootloader: (efi-bootloader partition: "/dev/vda1")
  file-systems:
    (list (file-system device: "/dev/vda2" mount-point: "/")
          (file-system device: "/dev/vda1" mount-point: "/boot"
                       type: "vfat" options: "rw,umask=0077"))
  users: (list (user-account name: "root" uid: 0 gid: 0 home: "/root"
                             password-hash: "!")
               (user-account name: "operator" uid: 1000 gid: 1000
                             home: "/home/operator" password-hash: "!"))
  packages: %base-packages
  features:
    (append
      (list
        (dhcp-feature)
        (nginx-feature redirect-http: #f http-root: "/etc/web-server")
        (simple-feature 'site etc-files-feature
          (list (etc-file path: "web-server/index.html"
                          text: "<!doctype html><title>Harbor</title><h1>Hello from Vessel!</h1>\n"))))
      (modify-features %server-features
        (ssh-server-feature authorized-keys: public-key))))

Verified

The imports give the file its system records, network, nginx and SSH features, and Linux package. The builder reads AUTHORIZED_KEY_FILE, validates its public-key lines, and supplies only those lines to public-key. The configuration doesn't read the raw input file. No private key enters the image.

The file returns a system-configuration, the same kind of value as the system.sgl the installer writes. The builder composes it with its features, and the manual composes it on every build to check that it gives nine services, among them nginx, the SSH server and the firewall. host-name names the machine harbor; kernel selects Linux. The kernel parameters put its console on the VM's serial port and keep a panic visible there. The EFI bootloader uses the first virtio disk's first partition. The two filesystem rows mount its root partition and its EFI system partition at / and /boot.

The required root account is followed by operator, with its own home and numeric user and group IDs. Both set password-hash to !, locking console password login while keeping SSH keys usable. %base-packages supplies the ordinary system tools. The dhcp feature asks the network for an address on eth0. That works with QEMU's user-mode network.

The nginx configuration disables the HTTPS redirect and sets http-root to /etc/web-server. nginx contributes its own TCP port-80 firewall rule and boot health check. The site feature writes index.html into that directory through etc-files; this small site is part of the image, so it doesn't need a separate upload. nginx returns 404 for a file that isn't there and doesn't list directories.

Finally, %server-features adds the base services, nftables firewall, SSH server, and cron. modify-features gives SSH your public key. This feature's key file applies to every account, including root, so use only keys you trust to administer the machine. SSH refuses password authentication, and both console accounts are locked. The firewall allows SSH on 22 and HTTP on 80.

Build the disk

On the prepared Linux build host, from the repository root, set AUTHORIZED_KEY_FILE to the absolute path of your public key, usually ~/.ssh/id_ed25519.pub. Set VESSEL_BUILD_STORE to your package store, SEED_ROOT to its seed, SIGIL_BIN to the bootstrapped Sigil executable, and ZIG_BIN to the checkout's pinned Zig executable.

The EFI selector must match this checkout. If you've already built it with image/build-efi.sh, set SELECTOR to its BOOTX64.EFI. Otherwise the example builds it with that helper, which also needs UEFI_SOURCE, HOST_SIGIL, HOST_LIB, and SIGIL_UI for the matching runtime and UI source. These are the same firmware inputs used to build Vessel's other images.

Run sigil -L src -L packages/vessel-service-schema/src -L packages/vessel-feature-engine/src docs/manual/examples/web-server/build.sgl /tmp/web-server-image. The output directory must be new. The builder loads the file shown above, realizes its packages through the channel, and writes a system lock and the source file's SHA-256 beside the image. Its final line starts with WEB-SERVER-BUILD-OK. The bootable raw disk is /tmp/web-server-image/disk/disk.raw.

To change the page, edit the etc-file text and build a new image. To serve a larger site, declare its files in the configuration or arrange a separate persistent filesystem for its root directory.

Boot and check it in QEMU

Run this step on a Linux host with Sigil 0.24.6 or newer, QEMU, qemu-img, OVMF, OpenSSH and curl installed. It can be the same computer that built the image. The Vessel guest needs none of those tools.

Set OVMF_CODE and OVMF_VARS to your OVMF firmware code and variable-store template. Set SSH_KEY_FILE to the private key that matches the public key you built into the image. Then run sigil docs/manual/examples/web-server/check.sgl /tmp/web-server-image /tmp/web-server-check. The evidence directory must be new too.

This boots the image through EFI with one virtual CPU and 1 GiB of RAM. It uses a disposable qcow2 overlay, leaving the original disk available for another boot. Only user-mode networking is needed: host loopback port 22360 forwards to guest SSH port 22, and 22361 to guest HTTP port 80. Pass a different base port as the third argument if those ports are busy.

The check logs in as operator with your key, fetches the exact page with curl, rejects console login as root, and requests a missing file to check for 404. It also proves that same-owner symbolic links below the static root cannot serve an outside file or directory; the configured root itself may resolve through Vessel's store links. It then gives nginx a nonexistent root directory: the same page check must fail. After restoring the root, the page must pass again. A successful run prints WEB-SERVER-CHECK-OK and stops QEMU. Keep receipt, serial.log, and qemu.log as evidence; delete the disposable overlay after you've collected them.

Copy to another QEMU host

If the build host doesn't run QEMU, transfer the result after building. From the checkout on the build host, run sigil docs/manual/examples/web-server/copy-to-qemu.sgl /tmp/web-server-image qemu-host /tmp/vessel-web-server. Replace qemu-host with your SSH host alias, configured for the account you use on that computer. The remote destination must be new. This uses scp to send the raw disk, its source hash and lock, and the standalone checker, then verifies the received disk's SHA-256. No private key or package build store is copied.

Log in with ssh qemu-host. On that computer, set SSH_KEY_FILE to its matching private key, and OVMF_CODE and OVMF_VARS to its local firmware files. Run sigil /tmp/vessel-web-server/check.sgl /tmp/vessel-web-server/image /tmp/web-server-check. The same SSH, console, page, missing-file and symlink checks now run on that host. This transfer and boot path doesn't require QEMU on Vessel.

Use a real VM

Choose an x86_64 VM host that accepts raw disk images, boots through UEFI, provides virtio disk and network devices, and offers a serial console. Upload the built disk.raw as its boot disk, or write it from the host's rescue environment. The image contains a partition table, so it belongs on the whole virtual disk. Use the host's image-import procedure and confirm the target disk before writing it.

Keep DHCP if the host supplies it. Otherwise replace dhcp with static-networking, using the host's interface name, address, prefix, gateway and DNS servers. Rebuild before uploading. The QEMU loopback address and forwarded ports are for the local check; on the VM, connect to its assigned address on ports 22 and 80. Point your domain's DNS record at that address and allow those ports in any host firewall.

HTTP is enough for this local demonstration. Before serving private data or logins, use TLS. Vessel's certificates feature and HTTPS vhost contributions support a domain's certificate and static locations. That requires a real domain, certificate issuance, and port 443; changing a DNS record alone doesn't enable HTTPS.

Created with Sigil