4.4 KiB
Interactive live logs
RustProxy provides an operator CLI that follows structured request/error events from every HTTP vhost:
rust-proxy --livelogs
The command connects only to the loopback administration listener and creates a bounded local CLI session from the private RustProxy database. When ./data/config.sqlite3 is absent, the bare command discovers common installed layouts: /var/lib/rustproxy is preferred on Linux/non-BSD systems and /var/db/rustproxy on BSD/OPNsense-style installations, with the alternate convention checked as a fallback. An explicit --data-dir always wins and custom installations should pass the same path used by the service. --admin-listen can select a non-default loopback port.
Administration HTTP/HTTPS transport
The CLI first probes the loopback administration /healthz endpoint over HTTP. An HTTP-only administration listener stays on HTTP; the 308 Permanent Redirect emitted by a TLS-enabled administration listener switches the CLI to HTTPS before a CLI session cookie is sent. HTTPS is pinned to leaf certificates present in the private <data-dir>/certs directory, so a configured self-signed administration certificate does not require a system trust-store installation.
This fixes the previous reconnect loop where --livelogs treated the TLS listener's expected HTTP-to-HTTPS 308 response as a stream failure. The same local transport selection is used by CLI config and certificate API operations.
The live path is separate from configured file/syslog sinks. Request processing publishes into a bounded Tokio broadcast channel without waiting for viewers. A slow viewer receives an explicit gap event with the number of entries lost from that viewer's live queue. The CLI also consults the retained history after connecting/reconnecting and de-duplicates entries by request id. Each request now carries a fresh 64-hex-character SHA-256 request_id; the same protected value is forwarded to the backend as X-Request-ID for correlation.
User-Agent, country and Traffic analytics
Structured access entries expose user_agent and country as selectable source fields in addition to the standard entry. User-Agent capture is enabled by default and is bounded before it enters retained logging/analytics state. Country capture is disabled by default because it requires a GeoIP lookup. With country capture disabled, GeoIP is kept off the normal request path unless a configured country access rule or country rate-limit already requires the lookup; in those policy cases the lookup still occurs for enforcement, but the country is not retained in access logs unless capture is enabled.
The authenticated Traffic workspace aggregates completed requests per vhost without database writes. The request path uses a bounded non-blocking queue, and high-cardinality dimensions use fixed-capacity approximate top tables. The page shows aggregate requests, 5xx errors, request/response bytes and mean duration plus top countries, User-Agents, effective client IPs, paths, routes, methods, status classes and cache outcomes. Donut charts summarize countries, User-Agents, client IPs, methods, status classes and cache outcomes while the bounded tables retain exact displayed labels/counts from the approximate TOP state. The lists are process-lifetime diagnostics, are not persisted across restart, and may drop analytics samples under overload rather than applying backpressure to proxy traffic. Country rankings are populated only while country capture is enabled. Client-IP rankings use the same verified effective client identity used by ACL/logging after trusted-proxy processing.
Interactive commands
No regex language is required. Type commands while the stream is running:
host api.example.com
vhost api
backend origin-a
route users
client 192.0.2.10
method GET
transport h2
cache MISS
status 5xx
path /api/
errors on
slow 250
detail on
filters
show 12345
pause
resume
reset
clear
quit
Use * to clear a scalar filter, for example backend *, and slow off / errors off for boolean filters. show ID prints the complete retained structured event for that request. detail on expands the continuously printed view with route/upstream/cache/transform/WebSocket/H3/byte metadata.
The server revalidates the streaming session every 10 seconds rather than writing session state for every request. Password changes, session revocation or expiry therefore terminate an existing stream within that bounded interval.