Network and TLS

The listeners, load balancers and proxies, browser origins, TLS for clients from files or ACME, and the authenticated listener between processes.

Listeners

ListenerOptionDefaultServesWho reaches it
Publiclisten.public0.0.0.0:7700The HTTP API, realtime sessions and the administration APIClients, through TLS
Operationslisten.operations127.0.0.1:7702/livez, /readyz, /status, /metricsHealth checks and metrics, privately
Internallisten.internalnoneRequests and sessions forwarded between processesThe deployment's other processes only

With public-tls.mode acme, the public listener's default is 0.0.0.0:443. Listeners may not overlap. The operations listener is unauthenticated, and answers nothing that names a document, a client or a credential: keep it private anyway.

The public listener

PathWhat
/v1/databases/{db}/…The HTTP API for documents, outcomes, document tokens and presence leases
/v1/sessionsRealtime sessions, over WebSocket
/v1/admin/…The administration API

Every request is authenticated by its own credential; no path of the public listener is unauthenticated.

Behind a load balancer or proxy

  • The load balancer must pass WebSockets through. The server pings each session's socket every 20 seconds and closes one that answered nothing for 60; allow idle connections of at least a minute.
  • Route only to processes whose /readyz answers 200 on the operations listener. A stopping process turns unready at once, closes its sessions unavailable (clients reopen elsewhere from where they were) and lets requests in progress finish.
  • No session affinity is needed: any process serves any request and forwards it to the process holding the document's partition.
  • Set public-url to the URL clients use.
  • Client addresses come from the connection. Set gateway.trusted-proxies to the addresses or networks of your proxies, and only those: the server then takes a request's source from their X-Forwarded-For. Per-source bounds use it; an IPv6 source is counted by its /64. It is read again on SIGHUP.
  • The server bounds the work each source can cause before it is authenticated, but tracks clients no further. Put a rate limiter in front of it for bursts of connections and password logins from single addresses. A client that stops reading is cut off after 60 seconds.

Browser origins

The deployment setting cors_origins lists the origins browsers may call the HTTP API from, separated by commas, or *:

mimicd admin settings set cors_origins=https://app.example.com,https://admin.example.com

Every process follows it within a second. The server reads no cookie and never sends Access-Control-Allow-Credentials, so a page can only use credentials it holds itself. A document token's own origins still apply to it.

An application whose browser code only opens sessions with document tokens does not call the HTTP API from the browser, and needs no CORS origin: sessions are WebSockets.

TLS for clients

public-tls.mode chooses how the public listener serves TLS:

ModeWhat
filesServes public-tls.cert (the chain, leaf first) and public-tls.key, which you renew
acmeOrders a certificate for the host of an https public-url from acme.directory, and renews it
offPlain HTTP, behind a proxy that terminates TLS
autoThe default: files when files are given, acme for an https public-url without a port, else off

Never publish plain HTTP beyond the loopback or a private network.

Certificates from files

The files are read again on SIGHUP and every 30 seconds. Renew them by renaming complete files into place. Any client that writes files, DNS-01 included, works this way.

Certificates by ACME

mimicd serve --public-url https://mimic.example.com --acme.email ops@example.com
  • One certificate per domain is shared by every process of the deployment, ordered by one of them and kept in the home store, which keeps to the certificate authority's rate limits. Let's Encrypt is the default directory.
  • Challenges are answered by tls-alpn-01 on the public listener, so port 443 must reach every process; or by http-01 on acme.http-listen (0.0.0.0:80).
  • /status shows the certificate's expiry and any failing order (acme_failing); mimic_certificate_expiry_timestamp_seconds exports the expiry.
  • The certificate's and the account's keys are kept in the home store, so the store's backups and replicas carry them: guard them as you guard the endpoint. Under sealer_mode = aead they are sealed (see Security).
  • mimicd admin pki clear-domain DOMAIN [--revoke] forgets a domain's certificate, which is ordered again while a process serves the domain; --revoke revokes it first. mimicd admin pki clear-account DIRECTORY deactivates the ACME account at its directory and forgets it.

Between processes

Processes of a deployment reach each other only on the internal listener, over mutual TLS 1.3: each end proves itself before a byte of a request is read. There is no plaintext or unauthenticated mode. Configure it the same way on every process, one of two ways:

  • A shared secret. internal.secret-file names a file of at least 32 random bytes, the same on every process. Each process derives a key from it and accepts exactly the peers that hold it. The secret never crosses the wire, but it must be random, never a password:

    (umask 077 && openssl rand -base64 48 > /etc/mimicd/internal-secret)
  • Certificates of your own PKI. internal.tls-cert, internal.tls-key and internal.tls-ca: each process presents its certificate and checks the other's against the CA. With internal.tls-peer-name (a SAN URI such as spiffe://example/mimicd, or a DNS name), each end also requires the other's certificate to carry that name; without it, every certificate the CA signed is a peer, so the CA must be the deployment's own. The files are read again every second.

advertise.internal is the address peers dial, when it is not listen.internal's (a process listening on 0.0.0.0 needs one). Bind the internal listener to a private network, and never expose it.

To PostgreSQL

Every process reaches every store. Reach a store on another host over TLS, with sslmode=verify-full in its URL. See PostgreSQL stores.