Installation
The proxy is distributed in two forms: as a single binary, and as a container image. Both read the same configuration file and behave identically.
A new installation starts from a minimal configuration that enables only the management interface. Destinations, routing, mappings and listeners are then added from the web interface, which validates each change and applies it without a restart. The proxy init command writes this minimal configuration; the container image and the install script both run it on first start, so it is rarely called by hand.
Initial configuration
Section titled “Initial configuration”proxy init creates a configuration directory with everything the management interface needs, and nothing else:
proxy init /etc/proxy --admin-bind 127.0.0.1:9443The command writes the following into the directory:
config.toml, a configuration with an[admin]table, an[admin.allow]table and a[tls.certificate.admin]entry.admin-token, a random token of 64 hexadecimal characters that signs in to the interface and the API.certs/admin.crtandcerts/admin.key, a self-signed certificate for the management interface, valid forlocalhost,127.0.0.1and::1, and for the bind address when it is a specific address.- An empty
mappings/directory.
Every file is created readable by its owner only, and any directory the command has to create gets mode 0700. An existing directory keeps its mode; the install script, for example, sets the configuration directory to 0750 before running the command. --admin-bind sets the management address and defaults to 127.0.0.1:9443. The generated configuration enables config_write, so the interface can change the configuration from the start.
The [admin.allow] table limits what the interface and API may configure later: listeners may bind only the usual mail and web ports (24, 25, 80, 110, 143, 443, 465, 587, 993 and 995) and any port from 1024 upwards except the management port, and destinations may point only at the usual mail ports, 443, 8080 and 8443. This table is read-only through the API, so only someone with access to the file on the host can widen it. Security explains the allowlist and why it exists.
On success, the command prints four lines: the configuration path, the token file, the address of the interface and the SHA-256 fingerprint of the generated certificate:
config: /etc/proxy/config.tomltoken file: /etc/proxy/admin-tokenadmin UI: https://127.0.0.1:9443/ui/certificate sha256: 5E:0B:...:9CThe token itself is never printed. The fingerprint identifies the self-signed certificate when the browser asks whether to trust it; comparing the two rules out an intercepted connection.
proxy init never overwrites a configuration. When config.toml already exists, it writes nothing and exits with status 3, which lets scripts call it unconditionally. A usage error exits with status 2, and any other failure with status 1. The command also refuses, with status 1 and no file written, directories that would let another user take over the management plane by replacing files in them. The target directory, certs/ and mappings/ are refused when they are writable by every user, and certs/ and mappings/ also when they are symbolic links; a target directory given as a symbolic link is followed. The target directory and certs/ must in addition belong to the user running the command. A directory writable by its group is accepted with a warning. The target directory is checked before the existing configuration, so a target directory writable by every user exits with status 1 even when it holds a config.toml. The files are written under temporary names and renamed into place only once all of them are complete, so an interrupted run leaves no partial configuration behind.
Container image
Section titled “Container image”Images are published to the GitHub Container Registry as ghcr.io/stalwartlabs/proxy, and to Docker Hub as stalwartlabs/proxy, with the same tags on both. Each release is built for amd64, arm64, armv7 and armv6, in two variants. The default image is based on Debian and glibc. The Alpine image is based on musl, and its tags carry the -alpine suffix. The tags are:
| Tag | Image |
|---|---|
v2.0.0 | One release exactly |
v2.0 | The newest patch release of one minor release |
v2 | The newest release of one major release |
latest | The newest release |
During a migration, use a tag that names one release exactly, such as v2.0.0. Recreating the container then cannot change the proxy’s version in the middle of the migration.
Every image is signed with cosign keyless signing, and carries a build provenance attestation in the registry. cosign verify and gh attestation verify check them.
The image reads its configuration from the /etc/proxy volume and runs proxy /etc/proxy/config.toml. It runs as the unprivileged user stalwart-proxy (uid 2000), with the CAP_NET_BIND_SERVICE capability, which allows it to bind the mail ports below 1024. It exposes ports 24, 25, 110, 143, 465, 587, 993, 995, 4190, 443 and 9443.
When the container starts and /etc/proxy/config.toml does not exist yet, the entrypoint first runs proxy init /etc/proxy, then prints the init output and the command that reads the token to the container log. An existing config.toml is never touched, so a configured volume starts exactly as before. The mounted directory must be owned and writable by uid 2000, and not writable by every user, because the init step writes there and the proxy saves configuration changes made in the interface to the same file.
Inside the container, the management interface binds to 0.0.0.0:9443, because an address on the container’s loopback interface cannot be published with -p. The PROXY_ADMIN_BIND environment variable changes this address; the entrypoint reads it only when it runs the init step, so it has no effect once the configuration exists. A wildcard bind inside a container has consequences that publishing alone does not control:
- Every container on the same Docker network reaches the management port, whatever
-ppublishes. - With
--network host, the port listens on every interface of the host. Such deployments set-e PROXY_ADMIN_BIND=127.0.0.1:9443on the first start. - A bare
-p 9443:9443publishes the port on every host address, and Docker’s port publishing bypasses host firewalls such as ufw. Publish it as-p 127.0.0.1:9443:9443instead.
The [admin] table cannot be changed from the interface, so narrowing the bind later means editing config.toml on the volume and restarting the container. Security explains why the management port must stay on the loopback interface or a trusted management network.
The image also has a built-in health check. It requests the management health endpoint at the URL in the PROXY_HEALTHCHECK_URL environment variable, by default https://127.0.0.1:9443/healthz. The container therefore reports itself unhealthy when the management interface is not enabled at that address.
A first deployment mounts an empty host directory and publishes the management port on the host’s loopback interface:
mkdir -m 0700 /srv/proxy && chown 2000:2000 /srv/proxydocker run -d --name proxy \ -v /srv/proxy:/etc/proxy \ -p 127.0.0.1:9443:9443 \ -p 25:25 -p 993:993 -p 995:995 -p 143:143 -p 110:110 \ -p 587:587 -p 465:465 -p 4190:4190 \ -p 443:443 \ ghcr.io/stalwartlabs/proxy:v2.0.0The same deployment, as a Compose service:
services: proxy: image: ghcr.io/stalwartlabs/proxy:v2.0.0 restart: unless-stopped volumes: - /srv/proxy:/etc/proxy ports: - "127.0.0.1:9443:9443" - "25:25" - "993:993" - "995:995" - "143:143" - "110:110" - "587:587" - "465:465" - "4190:4190" - "443:443"The token that signs in to the interface is read with docker exec proxy cat /etc/proxy/admin-token.
Install script
Section titled “Install script”On a host, the install script installs the binary, a service account and a service definition, and creates the initial configuration on a fresh install. It downloads the release archive for the host from https://github.com/stalwartlabs/proxy/releases/latest/download, so the host needs outbound HTTPS access and curl or wget. Linux and macOS are supported. The script runs as root:
curl --proto '=https' --tlsv1.2 -sSf \ https://raw.githubusercontent.com/stalwartlabs/proxy/main/install.sh | sudo shTo install from an archive already on the host, for example one verified by hand, set PROXY_ARCHIVE to its path. Without an argument, the script installs into the standard locations:
| Component | Path |
|---|---|
| Binary | /usr/local/bin/proxy |
| Configuration | /etc/proxy/config.toml |
| Certificates | /etc/proxy/certs/ |
| Mapping files | /etc/proxy/mappings/ |
| Management token | /etc/proxy/admin-token |
| Environment file | /etc/proxy.env |
With a directory argument, such as install.sh /opt/proxy, the script installs a tree under that directory instead, with the binary in bin/, the configuration, token and certificates in etc/, and the environment file at proxy.env in the top directory.
The script creates the service account stalwart-proxy (_stalwart-proxy on macOS); the name avoids a collision with the proxy user that Debian ships. Depending on the platform, it then installs a systemd unit, an init.d script on hosts without systemd, or a launchd property list. The systemd unit grants CAP_NET_BIND_SERVICE, raises the open-file limit for many concurrent connections and restarts the proxy when it fails. The proxy logs to standard output and standard error, which the systemd journal collects.
When no configuration exists yet, the script hands the configuration directory to the service account and runs proxy init on it as that account, with the management interface on 127.0.0.1:9443. The service account must own the directory because the proxy saves changes made in the interface back to config.toml, writes uploaded certificates into certs/, and keeps earlier versions of the file next to it. The script then starts the service and prints the init output, followed by the command that reads the token (sudo cat /etc/proxy/admin-token). Because the interface listens on the loopback interface, an SSH tunnel such as ssh -L 9443:127.0.0.1:9443 <host> reaches it from another machine.
An existing configuration is never overwritten, and neither is an existing environment file, so re-running the installer on a host where the proxy is already installed keeps a customised deployment. It does rewrite the service definition (the systemd unit, the init.d script or the launchd property list) and resets the ownership and mode of the environment file, so changes made to the unit file itself are lost; systemd settings belong in a drop-in file, such as one created with systemctl edit proxy, which survives. The script writes the new binary under a temporary name and renames it over the old one, so the running process is not disturbed by the copy. It then restarts the service when it is running, and prints that it did; a stopped service stays stopped, and the script prints the command that starts it.
Re-running the installer on a running proxy therefore ends every live session. On the stop signal, the proxy closes its listeners and waits up to server.shutdown_grace (30 seconds by default) for open sessions to finish, then exits and closes the ones still open; the service manager can cut this wait short, as described under Lifecycle. New connections are refused until the new process has bound its ports, and clients whose sessions were closed have to reconnect. During a migration, re-run the installer at a quiet time.
Release verification
Section titled “Release verification”The install script does not verify what it downloads. Verification is available for a manual installation instead. Each release archive on the releases page is accompanied by a Sigstore bundle (<archive>.sigstore.json), and covered by a GitHub build provenance attestation. To verify an archive before installing it, download it, check it with gh attestation verify <archive> --repo stalwartlabs/proxy, and pass its path in PROXY_ARCHIVE. Releases publish no checksum files.
Environment file
Section titled “Environment file”The service reads the environment file before starting the proxy. It holds KEY=VALUE lines and offers two settings, both commented out:
PROXY_ADMIN_TOKENsupplies the management token, and takes precedence over the token file.RUST_LOGoverrides the configured log level with a tracing filter expression.
The file lives outside the configuration directory and belongs to root, readable by the service account. The service account can change everything inside the configuration directory, including through the management interface, so keeping the environment file elsewhere ensures that nothing the proxy can write is ever read by the service manager as root.
First sign-in
Section titled “First sign-in”With the proxy running, open the address printed by the init step, such as https://127.0.0.1:9443/ui/, in a browser. The browser warns about the self-signed certificate; accept it only after comparing its SHA-256 fingerprint with the one printed by the init step. Sign in with the content of the token file.
On a new installation, the overview shows a setup guide that walks through the remaining steps: adding a destination, choosing it as the default destination, optionally connecting a mapping store and adding a TLS certificate for the mail host names, and adding listeners. Each change is reviewed, validated and applied live, as described under web interface.
Running the binary
Section titled “Running the binary”The binary takes the path of its configuration file as its first argument, or reads it from the PROXY_CONFIG environment variable:
proxy /etc/proxy/config.tomlAt startup, the proxy validates the configuration, binds the management interface and every configured listener, and starts serving. A configuration error, or an address that cannot be bound, stops it before it serves any session. On SIGINT or SIGTERM, it stops accepting connections and lets established sessions finish within the configured grace period before it exits. The configuration file is described next.