Reiki

Security proxy for agent and LLM traffic: isolates keys, filters what leaves, keeps access reliable

View the Project on GitHub ddproxy/reiki

Tunnel

The [tunnel] section starts a second listener that works as a CONNECT forward proxy. A client that honours HTTPS_PROXY (most runtimes and tools do) asks it to open a TCP connection to host:port. By default Reiki copies bytes in both directions without reading them, so the client’s own TLS session, HTTP version and headers reach the destination exactly as the client made them.

[tunnel]
listen = "127.0.0.1:4099"
allow = ["api.example.com", "*.example.net"]
connect_timeout_secs = 10
HTTPS_PROXY=http://127.0.0.1:4099 NO_PROXY=127.0.0.1,localhost some-client
Key Default Meaning
listen required Address to listen on. Must differ from listen and the admin address. Keep it on loopback or a private interface: the listener has no authentication.
allow required Destinations a client may open: host, host:port, *.host (subdomains, not the apex) or *. A bare host means port 443. A request for anything else gets 403.
connect_timeout_secs 10 How long to wait for the destination to accept the connection.
allow_loopback false Lets the tunnel reach loopback addresses. For tests and local development only.
deny_private false Refuses private-range addresses: RFC 1918, 100.64.0.0/10 and IPv6 unique-local. Turn it on with a broad allowlist such as * so the tunnel reaches the internet and not the local network.
intercept none Reads the traffic of chosen hosts; see below.

What it does and does not do

Interception

An opaque tunnel cannot be logged, masked or given a key. [tunnel.intercept] changes that for the hosts you list: Reiki answers the client’s TLS handshake itself with a certificate signed by a CA the client trusts, reads the HTTP request, and sends it through the same path as a normal route, then re-encrypts it on its own TLS session to the real upstream. Plugins, key selection, failover and rate limits all apply.

[tunnel]
listen = "10.0.0.1:4099"
allow = ["api.example.com"]

[tunnel.intercept]
ca_cert = "/etc/reiki/ca/ca.pem"
ca_key = "/etc/reiki/ca/ca.key"
leaf_ttl_hours = 24
require_auth = true       # CONNECT to a stream host must carry the stream token
ca_key_permissions = "error"   # refuse a CA key that group or others can access; "warn" only logs

[[tunnel.intercept.hosts]]
host = "api.example.com"
upstream = "example"      # an [upstream.*] whose base_url is on this host
stream = "client-a"         # the stream whose key chain serves it; omit for a passthrough upstream

Create the CA, name-constrained to the hosts it may sign for, and give only ca.pem to clients:

reiki ca-init --dir /etc/reiki/ca --host api.example.com --days 365

A CA is limited to the hosts it was created with, so adding a host means creating a new one with --replace, giving clients the new ca.pem, and reloading. reiki check prints the days the CA has left, startup logs a warning within 30 days of expiry, and GET /status reports intercept.ca_days_left.

Clients must trust that certificate: add it to the system store, or point the runtime at it with SSL_CERT_FILE or NODE_EXTRA_CA_CERTS, whichever the client reads.

Trust boundary

A plain CONNECT to a host on the allow list needs no credential: the list is the only gate, and "*" is a legal rule that opens every HTTPS site. Only intercepted hosts check the stream token. Put the tunnel listener on a network that only trusted clients can reach, keep deny_private = true so it cannot be used to reach the local network, and keep allow as short as the clients need. deny_private covers RFC 1918, shared address space, benchmarking and the IETF protocol block, unique-local IPv6, and the IPv4 forms embedded in IPv4-mapped, NAT64, 6to4 and Teredo addresses.