plexus / vpn · case study
DERU
ENGINEERING CASE STUDY · A MESSENGER'S VPN SERVICE

How Plexus VPN works

Plexus VPN is a network service integrated with the Plexus Messenger ecosystem. It combines account-based access management, stable subscription links with dynamically generated responses, traffic accounting, quotas and connection-parameter lifecycle management.

The system separates the control plane, which makes access and configuration decisions, from the network components that carry user traffic. This case study covers the architecture, the engineering decisions and the lessons learned from operating the system as it evolved.

messenger account→ subscription link→ nginx :443→ xray→ open internet
This is an engineering walkthrough of the current production implementation — not a user guide and not an availability guarantee (not an SLA). Routes, components and limits are described as of publication and may change. The user-facing page is vpn.
Parameter
Value
Purpose
VPN access within the Plexus ecosystem
Management
account + plexus-core; the gateway is driven by plexus-vpn via Xray's internal API
Configurations
personal, subscription link, up to 8 per account
Quotas
per account, UTC month
Primary transport
VLESS + REALITY behind L4 SNI routing on TCP/443
Status
production · access gated by account permissions
Key decisions
01 — The service's user model

VPN as part of the Plexus ecosystem

Plexus VPN is not a set of static configs but a service tied to the messenger's account and permission system. Once granted the permission, a user creates connections in settings — up to eight separate configurations per account — and gets a subscription link for each: a stable URL the client application periodically polls for the current set of routes. VPN management is decoupled from messaging: the network plane needs no access to message contents.

02 — Engineering challenges

The network constraints the system had to work under

Some users sit behind networks with active filtering, and the restrictions there hit different layers: destination address (blocks and connection “freezes” toward foreign hosting IPs), TLS metadata (an SNI name not matching the address's network segment), transport characteristics (WireGuard/OpenVPN/AmneziaWG protocol signatures) and connection behavior. Not every provider applies all of these mechanisms — but the architecture had to withstand each one actually observed in the networks in use; this is not a description of all networks and operators at once.

Hence the system requirements:

03 — System architecture

The control plane and the network plane

Control plane — the authoritative VPN state: account binding, permission checks, peers, quotas, the desired configuration. Decisions are made by plexus-core (its database holds the desired and authoritative state — the single source of truth on rights, peers and quotas) and applied by plexus-vpn — a separate executor service with no authoritative user-state store of its own. Data plane accepts connections, runs user sessions and forwards traffic over the configured routes: the nginx SNI router, the Xray network engine, the Caddy HTTP front and the RU L4 relay.

Terms: a peer is an internal access record bound to an account and a set of connection parameters; it is not necessarily a separate device. An inbound is an ingress profile accepting VPN connections in Xray (each with its own transport and decoy domain). A peer is registered on all current inbounds at once — one key, several ways in. Web ingress and the VLESS inbounds share the Hetzner host's single external TCP/443 (the ss-fallback and AWG ports are separate) — the messenger site lives on it too. nginx reads only the SNI in ClientHello and decides at the transport layer who gets the connection: decoy-domain names go to Xray, everything else to Caddy, which serves the web and API. On the VLESS/REALITY path neither of them terminates client TLS.

ACCOUNT permissions VPN access · RU egress AWG · quota tiers PLEXUS-CORE source of truth peers · subscription tokens quotas · counters · epochs subscription · admin API sweep reconcile · 5 min PLEXUS-VPN executor no DB · uuid registry xray api: add/remove peer · stats GATEWAY xray in + out
control plane: access decisions flow top to bottom; client traffic never touches them

plexus-vpn is better described not as a “stateless executor” but as a VPN configuration worker: the source of truth is the core database; the service itself stores only the list of issued uuids and applies decisions via the Xray API (the api inbound is reachable only inside the isolated docker network). After a restart the worker does not restore “its own” state — periodic reconciliation compares the key set on the gateway with the database and brings it into line; operations are designed idempotent: a repeated reconcile should converge the gateway to the same state, not multiply entities (actual behavior depends on the operation result and on Xray API error handling).

The plexus-vpn internal token is limited to the VPN namespace and does not open the messaging API. Its compromise still leaves risks around VPN access and configuration management — but it is not a universal messenger credential.

Area
Technology
Role
VPN engine
Xray-core
VLESS sessions, egress routing, traffic counters
Primary transport
VLESS + REALITY
Two inbounds behind the SNI-split, different decoy domains
Network ingress
nginx stream
L4 routing of :443 by SNI before TLS termination
HTTP front
Caddy
Site, API
Relay
nginx (RU node)
TCP splice :443 → Hetzner host, no keys or state
Backend
Spring Boot, Java 21 ×2
plexus-core (state) + plexus-vpn (executor)
State
PostgreSQL
Peer registry, quota counters, service-wide counter
Deployment
Docker Compose
Two hosts; images are built on the Hetzner host
04 — Access lifecycle

How the subscription link works

Access moves through four states: creation (mint), periodic reconciliation with the database (reconcile), rotation (rotate) and revocation (revoke). Two different objects matter here. Subscription URL — a stable subscription link with a random token: the token is per-peer and is itself an access secret. Connection credentials — the parameters of a specific connection inside the subscription response (uuid, REALITY keys, short ID, SNI, fingerprint): they change on rotation and die on revocation, while the link outlives any key. The subscription re-reads the account's current rights on every request — lose the permission and the route disappears at the client's next refresh.

MINT

Issuance

The VPN permission and acceptance of the terms of use are checked (AUP acceptance is recorded as a flag on the row). The core asks plexus-vpn for a new key; it registers the uuid on all current inbounds via the Xray API. Limit — 8 configurations per account. The row gets its subscription token at birth.

RECONCILE

Reconcile

Every 5 minutes the key set on the gateway is compared with the database: missing keys are restored, orphans are removed, traffic counters are read into quotas. Operations are idempotent — but the sweep runs on both core nodes in parallel, with no leader lock (see the roadmap section).

ROTATE

Key rotation

An epoch is an internal version of the configuration generation in code: bumping it initiates a controlled rotation — the sweep reissues rows on the old epoch. Order matters: the old key's counter is read first, then a new uuid is created and only then is the old one removed; a failure between steps is corrected by the next reconcile. The quota is not reset and the subscription link does not change.

REVOKE

Revocation

Synchronous: the key is removed from the gateway at call time, the row is marked dead (“not found on gateway” is also a terminal state). In the current implementation the subscription immediately answers 404; new connections are rejected — already-open sessions are not forcibly torn down by a normal delete. Rows and counters are kept — for audit and monthly accounting.

⟳

The diagram is a state model, not a strictly linear pipeline: reconcile runs on a schedule for all live rows, while rotation and revocation are triggered by different events at different points in a configuration's life.

05 — Traffic accounting and quotas

How usage is counted

Four different mechanisms with different triggers and different recovery paths — worth telling apart.

Per-account quota

Service budget

Regional node limit

Concurrent-IP limit

A quota is an operational counter, not a per-byte billing system: accounting is periodic, so some error is possible between samples and on an unplanned restart.
06 — Network transports and routes

What a connection looks like from the network's side

The primary transport is VLESS + REALITY. The functions are worth separating: VLESS is the user-session protocol; REALITY is the connection-establishment mechanism that uses the parameters of a configured target TLS server (the decoy domain) and performs its own key-material check of the client; access issuance, keys and quotas are the Plexus backend's responsibility.

A connection without a valid key gets no refusal or dead socket — it is passed to the real target TLS server — loosely, the “decoy server” (in the current configuration, legitimate sites set in the camouflage configuration). That is why a single port :443 serves both VPN clients and ordinary requests. This yields a TLS-like external connection profile, but it is not a guarantee of traffic indistinguishability under every observation and analysis method — and this page makes no such guarantees.

scenario 1 · client with a key client + key xray · key check VLESS session → proxy scenario 2 · no valid key any connection xray · no key TLS decoy → real site
a simplified model for the configured profile — it does not automatically extend to all ingresses and transports
WHAT A NETWORK OBSERVER CAN POTENTIALLY SEE destination IP · port 443 · TLS name · timings · volumes — tunnel contents are not exposed.

Actual visibility depends on the observation point, the network path and configuration: the list above is what is fundamentally available on the path, not a claim that “the filter sees only this.”

Terms: an ingress path is the node through which the client establishes the VPN connection; an egress route is the node from which traffic leaves for the final resource. The RU relay is an ingress; the RU egress is a separate egress on the same host.

Ingress paths

Ingress path
Scheme
Status
RU relay
Client → RU relay (splice) → Hetzner host → internet
working — the only ingress in the standard subscription, served to every account; a probe checks the relay every minute, and while it does not answer the route drops out of the served set instead of advertising a dead link
direct VLESS+REALITY
Client → Hetzner host :443 → inbound → internet
working for networks outside the target segment, but not part of the standard subscription; in tests from RU a TLS session to a foreign hosting IP froze after ~16 KB — which is why the subscription serves the relay
xhttp via Cloudflare
Client → Cloudflare → Caddy → xray on the Hetzner host → internet
dormant reserve peers are registered on the inbound, but the route is not part of the subscription: the CDN path is unstable — specific operational scenarios, not an equivalent backup
shadowsocks
:8488 tcp+udp on the Hetzner host
emergency fallback manual setup, outside the standard subscription response — for specific operational scenarios, not an equivalent backup
AmneziaWG
Client → UDP to the Hetzner host → internet
experimental issued behind a separate permission, outside the subscription model; a noticeable UDP flow to a hosting IP is the first filtering candidate, so it is not handed out publicly

The subscription serves exactly the routes the account is entitled to: the base permission sees ingress via the RU relay; the RU-egress permission adds it to the set. The other transports are up and peers get registered on them, but they reach the user only through a config export — or not at all. The “working” statuses are a snapshot of observations in the scenarios used at publication time, not a guarantee of availability in every network.

Egress routes

Egress route
Path
Status
regular egress
Hetzner host → open internet
working with any ingress path
RU egress
Hetzner host → ss → RU xray → RU internet
working behind a separate permission

Separately, there is an outbound-abuse filter: the Hetzner host blocks the BitTorrent protocol, outbound SMTP, requests to private ranges and administrative ports — a hoster requirement driven by DMCA/scan reports, not a functional policy of the service.

07 — Security and privacy

Who can see what

In the configuration in use, Xray access logging is disabled (the access log is turned off by a setting — it is the one that would record client addresses and destination domains). That does not mean network metadata is not processed by other components: each link has its own visibility and its own logging.

Component
What it can technically see
What gets recorded
User network / ISP
Destination IP and port (on the relay path — the relay address), TLS name (decoy domain or CDN), timings, volumes and flow direction
Per provider policy — outside our control
L4 relay (RU)
Client IP, timings, volumes; does not decrypt the TLS stream
nginx system logs; no credentials at the splice-process level — the RU egress runs on the same host with its own configuration
edge-nginx
IP, SNI name, timings, splice volumes
Error log (IPs appear on connection drops); no access log configured for the stream config
edge-xray
Client IP (via the PROXY header), session uuid, destination domains (sniffing for routing), rx/tx counters
Access log disabled by setting — it is the one that would record connection addresses; what remains is the container's rotating service journal, the standard log level being warning. Counters live until restart — accounting is done by the sweep into the DB
Caddy
Real IP (PROXY header), HTTP metadata of the site and API
Standard web-server access log — the row concerns the site and API; VPN traffic does not pass through Caddy after L4 routing — except the dormant xhttp ingress via the CDN: its TLS terminates on Caddy, then the flow leaves for xray over the internal network
RU egress (xray)
Destination addresses of RU-egress traffic
Access log disabled by setting — xray's default wrote addresses to stdout/journald, an explicit none added after discovery (2026-11-26); the systemd service journal remains. Accepts only from the Hetzner host's IP (ufw) — a network-access restriction, not a privacy guarantee on the node itself or at the downstream providers
plexus-core
Account↔peers binding, quotas, the AUP flag, subscription tokens, bypass lists
Peer and counter tables; the client config is stored encrypted
plexus-vpn
Peer uuids and counters at runtime
No DB; a file of issued uuids in its own volume
Cloudflare
CDN TLS termination for the site's web traffic: URLs, headers, timings; page and API contents — within HTTPS
Per Cloudflare policy — only the site and API web plane
Hosting providers
Infrastructure-level network metadata
Per provider policy

The table describes the components' technical capabilities and the logging settings at the snapshot date: the ability to process data does not mean it is necessarily stored. Retention of our own journals is set by on-host rotation; provider policies are set by their terms.

Privacy and responsibility boundaries

Trust boundaries. Internal APIs are isolated from external access; VPN management is separated from the messenger API; client configs in the database are encrypted; the Xray api inbound is unreachable outside the docker network; the relay's splice process holds no credentials (the RU egress on the same host is a separate service with its own configuration), and compromising the splice would affect availability and expose transport metadata (client IPs, timings, volumes) — not user keys.

08 — Operations and figures

Current parameters and live probes

Verifiable configuration and operations parameters, plus the live self-diagnostics series below — the service still does not collect usage metrics in client networks (active users, real speeds and user-side uptime).

Infrastructure and limits

2
VPS nodes: the primary Hetzner host and a separate RU node combining the relay and the egress
443
the single public TCP port on the Hetzner host for the site and VLESS ingresses — after L4 SNI routing the streams diverge into different planes (ss/AWG ports are separate)
2
VLESS + REALITY ingress profiles on edge-xray; the set depends on account permissions and import format, xhttp is dormant, ss-fallback is manual, AWG is experimental
8
maximum configurations per account
5 min
gateway ↔ database reconcile period: restore, counters, quotas, epochs

Live probes

Infrastructure self-diagnostics: every 5 minutes a script on the Hetzner host measures four reference paths and writes the result to a public JSON. This is the server side — not a measurement inside a client network; failures are marked red.

Ingress via the RU relay
—
TLS handshake Hetzner → relay → Hetzner
Site via Cloudflare
—
HTTPS GET of the front page, as a browser sees it
RU egress
—
TCP connect to the egress service
Emergency ss-fallback on the Hetzner host
—
TCP connect to the fallback port

09 — Takeaways and further work

What operations taught

The architecture changed not only as a result of the initial design but also under the pressure of production operations. The main takeaway: a working transport configuration is only part of a reliable VPN service. Just as important are state consistency, shared-host resource planning, observability, controlled key rotation and predictable recovery. Below is an honest backlog: these are directions and statuses, not finished features.

Architectural trade-offs

Reliability

  • planned

    Leader lock for reconcile

    Both core nodes run the sweep in parallel: idempotency prevents breakage but not double rotations and races on key removal. The user-visible effect is extra key reissues; a postgres advisory lock is needed.

  • in progress

    Route health checks

    A full relay outage is already caught by the probe inside the service — the route drops out of the served set within a minute; but degradation — loss, rising latency — can still be first noticed by the client. Synthetic checks of every subscription route — from inside and outside — should catch degradation before user complaints. The first step is done: a probe on the Hetzner host already collects the live series for the “Live probes” section — next comes degradation assessment and a signal to a human.

Traffic infrastructure

  • planned

    Second relay

    A single RU machine is both a point of failure and a traffic ceiling (its monthly hoster budget is already protected by the guard). A second relay is capacity headroom and a step toward removing the single point of failure (a client-switchover procedure is still needed).

  • research

    Assessment of alternative transports

    Depending on a single implementation is a risk: analysis of HTTP/3 transports remains a research direction, not a promise of a specific release; the transport layer is kept replaceable.

Operations

  • observed issue

    Applied-config verification

    A config in the repository does not guarantee the container runs on it: bind-mounts and stale files have already cost a two-day degradation. A “what is actually applied” check after deploy is needed.

  • planned

    Observability and alerts

    The splitter and xray counters, the quota meters and the RU node's NIC metrics live in different places, and an incident showed that “written to the container log” ≠ “someone saw it.” A single overview plane is needed — usage metrics on the already-accumulating counters — plus delivery of the signal to a responsible human.

  • known limitation

    Deliver client-side bypass

    The full JSON can carry routing rules, but the universal vless:// link list cannot transport them — a client that imports only individual links does not get those rules. This is a limitation of the format and the current delivery method, not a guarantee that bypass works: rule correctness needs verification and delivery to clients that understand them.

10 — Author's contribution

What exactly was built in Plexus

Xray is the base network engine; everything that turns it into a service was designed and integrated inside Plexus: the account and permission binding, the subscription model, quotas, the key lifecycle, gateway-to-database reconciliation, deployment and operations. My role was architecture, task decomposition, implementation review and acceptance; AI tools were used on individual tasks — the requirements, verification and decisions to accept results are mine. Xray, nginx, Caddy and amneziawg-go are third-party components: the contribution is selection, configuration and integration, not authorship of the engines.