Introducing a new way to review your PRs.

Read the announcement

arcboxlabs / arcbox

Run AI agents on real and isolated machines — own kernel, filesystem, and network — with <100ms boot. Local first, OCI compatible, pure Rust.

View on GitHub

32 documents · Updated Nov 6, 2026

docs / machine-web-service-access

Machine web-service access

Machine web-service access lets a running distro machine publish an HTTP service through a stable machine name. The API discovers routes from the guest, the daemon keeps the guest configuration current, the engine carries the control session, and the guest agent owns the listener and request forwarding. The system publishes a URL only while the machine identity, DNS claim, bridge address, and installed route agree.

See Local service access and trust for the shared access model and Local CA and trust lifecycle for host trust and certificate lifecycle.

Machine web-service model

Machine web access has two linked paths. A control path configures and observes the guest through the agent. A data path accepts traffic at the machine's bridge address and forwards it to the selected guest service.

PathMain responsibilityResult
ControlAPI, daemon, engine, and guest agentRoute discovery, policy delivery, and lifecycle control
DataMachine bridge address, guest listener, and guest route rulesHTTP or HTTPS traffic reaches the machine service
NameRuntime DNS registry and host DNS projectionA canonical machine name resolves to the current bridge address
TrustHost CA signer and guest HTTPS sessionManaged HTTPS uses a valid certificate only for current ownership

Domain ownership

Canonical machine names

The runtime gives each running machine one exact web name under the machine DNS tree: <machine-hostname>.machine.<configured-domain>. The machine hostname is a DNS-safe form of the machine name. The claim owner is distinct from container ownership, so container reconciliation cannot remove a machine route.

The claim is valid only when all of these values match:

  • the expected machine name;
  • the current physical VM run;
  • the machine bridge IPv4 address;
  • the exact canonical DNS name; and
  • the current registry claim revision.

The System VM is not a machine web owner. Its web routes come from its own captured guest and its own index or container authority.

References: app/…/machine_dns.rs• L1-47 app/…/guest.rs• L225-288

DNS claims

The DNS registry is the authority for publication. It keeps built-in names reserved, records the owner and address together, and projects only the winning exact .local claims to host DNS. A wildcard claim can help resolve a name, but the public machine route itself remains an exact claim.

When a machine stops, loses its bridge address, or no longer owns the claim, the name becomes unavailable. The system does not keep serving a URL from a saved machine record.

References: app/…/dns_reservations.rs• L1-10 virt/…/dns_projection.rs• L12-57

Route discovery and publication

Guest route discovery

The guest agent reports installed web routes, not every listening socket. It reports the machine identity, bridge address, selected HTTP port, and HTTPS behavior after the guest has installed its route rules.

The runtime captures the machine before it asks the agent. It then checks the returned route against the captured name and address and checks the same DNS claim again. This prevents a reply from an old VM run or an old address from becoming a public URL.

References: app/…/list.rs• L78-124 app/…/list.rs• L224-260 engine/…/web_services.rs• L50-83

Listener and relay paths

The machine agent opens a private control session for one machine. It starts the guest web frontend before it acknowledges the session, then applies route rules that send traffic from the machine address to the selected application port. The frontend handles managed TLS and relays the HTTP request to the application.

The host-side session carries configuration and certificate authority data. Normal web traffic uses the machine's bridge address rather than the control session. This separation lets the machine keep serving its own web process without exposing a host listener for every guest port.

References: guest/…/machine_web.rs• L77-131 guest/…/machine_web.rs• L154-221 guest/…/routes.rs• L108-131 guest/…/http_relay.rs• L23-80

Port policies

Each machine stores one policy for HTTP and one for HTTPS. A policy can enable automatic selection, disable the protocol, or select a specific port. The daemon sends the complete policy set to the guest so a change cannot leave one protocol using stale settings.

Automatic discovery accepts a port only after the guest confirms that the service speaks the expected protocol. Native HTTPS takes precedence when the application serves its own TLS. Managed HTTPS is available when the guest frontend can terminate TLS.

References: engine/…/web_ports.rs• L1-106 guest/…/machine.rs• L31-63 guest/…/routes.rs• L271-340

API access and HTTPS

Service directory

SystemService.ListWebServices returns public URLs built from current DNS ownership and installed routes. With no hostname it returns the complete directory. With a hostname it resolves one concrete machine name and returns at most the matching service.

WatchWebServices emits changed complete snapshots. A guest or route failure ends the stream, so clients must discard stale entries and request a new snapshot. Clients must use the returned URLs instead of deriving URLs from saved or exposed ports.

References: app/…/system.rs• L464-505 app/…/web_services.rs• L8-27 app/…/list.rs• L128-175

HTTPS modes

Every published route has one of three HTTPS modes:

  • None: no HTTPS URL is available.
  • Managed: the guest frontend terminates TLS with the ArcBox local CA.
  • Passthrough: the application keeps control of TLS and its certificate.

Managed HTTPS applies only to names below the local CA namespace. A foreign custom name can still publish HTTP or native HTTPS, but it does not gain an ArcBox-managed HTTPS URL.

References: common/…/web_services.rs• L7-72 app/…/web_services.rs• L191-267

Certificate authorization

The daemon signs a guest certificate request only after it confirms that the requested DNS name belongs to the guest's current web service. It checks ownership before signing and again during and after signing. A change in DNS ownership, guest identity, or active CA invalidates the request.

The guest renews HTTPS access observation through a short lease. The host renews that lease only while the client can offer trust authorization. The certificate path therefore depends on both local CA state and current route ownership; CA trust alone does not make a machine URL reachable.

References: app/…/tls_signer.rs• L132-137 app/…/tls_signer.rs• L168-226 app/…/web_services.rs• L62-83

Lifecycle cleanup

Session lifecycle

When a machine becomes eligible, the daemon captures its physical VM and DNS claim, holds the machine through connection setup, and opens the guest session. The guest binds its frontend and route actor before it publishes the claim and acknowledges the open request. Policy, DNS, or CA changes cause a complete replacement with a higher source revision.

The session closes and starts again when the machine stops, the VM run changes, the bridge address changes, the exact claim changes, or the guest connection fails. This keeps a route tied to one physical guest rather than to a machine name that may later refer to another run.

References: app/…/machine_web.rs• L64-105 app/…/machine_web.rs• L109-205 guest/…/machine_web.rs• L154-288

Shutdown cleanup

Cleanup withdraws authority before the old route can be reused. The guest removes its DNS claim, clears installed web state, stops the frontend, and sweeps route rules. The daemon cancels and joins the machine worker, certificate signer, and HTTPS observer before stopping the runtime.

Shutdown order matters because a live listener or pending control task can still publish a route. The daemon retains these services through normal shutdown, startup cancellation, and startup failure.

References: guest/…/machine_web.rs• L200-299 guest/…/routes.rs• L173-189 app/…/shutdown.rs• L53-80

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the canonical machine name, machine DNS owner, guest route identity, and API URL projection in sync.
  • Preserve the captured physical VM and bridge address through agent connection, route validation, certificate signing, and cleanup.
  • Keep complete policy replacement and increasing source revisions aligned between daemon, engine, and guest agent.
  • If managed HTTPS changes, update both CA ownership checks and the guest frontend's authority source.
  • Keep route withdrawal ahead of frontend shutdown and runtime stop.

Important failure modes

TriggerConsequenceGuard
Machine bridge address changes during a sessionA stale URL can target the wrong guest or no guestRe-capture the machine and compare the exact DNS claim and address
Guest reports a route for another name or VM runAn unrelated listener could be publishedValidate the captured machine identity before projection
Managed HTTPS request arrives for a name no longer ownedThe certificate could authorize stale accessCheck ownership and claim revision before and after signing
Guest frontend fails before readinessThe control session never publishes a usable routeBind the frontend and route actor before the open acknowledgement
Session closes without route withdrawalOld DNS or NAT state can survive a stopped machineWithdraw claims and routes on EOF, cancellation, and shutdown

Key files

FileWhy to read it
app/…/system.rsPublic list and watch entry points
app/…/list.rsGuest capture, route query, and URL projection flow
app/…/guest.rsMachine identity and DNS claim validation
app/…/machine_dns.rsCanonical machine DNS publication
app/…/machine_web.rsRetained machine configuration worker
engine/…/web_services.rsHost-to-agent web RPC boundary
guest/…/machine_web.rsGuest session, publication, replacement, and withdrawal
guest/…/routes.rsGuest listener and route lifecycle
common/…/web_services.rsURL and HTTPS-mode projection rules
app/…/tls_signer.rsManaged certificate authorization