Kill TCP Overhead: Signed Sockets in ODAC.JS

November 23, 2026
9 min read
8 reads
Kill TCP Overhead: Signed Sockets in ODAC.JS

Every reverse-proxied Node.js application pays two quiet taxes on every single request. First, you push local container traffic through the kernel TCP stack even when the proxy sits on the exact same machine. Second, you either turn on a loose private-network trust flag (trust proxy) and pray no neighbour container spoofs X-Forwarded-For, or you hardcode brittle IP lists that break the moment your container network shifts.

ODAC.JS v1.8.0 eliminates both taxes in one release.

When running behind the ODAC Proxy, your application now automatically accepts HTTP requests and WebSocket upgrades over a private Unix domain socket while keeping its standard TCP port open as a non-fatal fallback. At the same time, we closed a classic header-spoofing gap by replacing blind private-IP trust with cryptographic HMAC-SHA256 proxy signatures and strict zero-trust defaults outside the ODAC server environment.

Show Me The Code: Zero-Config Transport, Accurate Metadata

The best infrastructure upgrade is one that requires zero rewrites in your business logic. Whether a visitor connects over HTTP/2, triggers a WebSocket upgrade, or gets routed over a Unix socket in Turbo Mode, your routes, middleware, and lifecycle hooks stay identical.

Here is a real-world setup spanning rate-limited form submissions, authenticated WebSockets, and sign-in auditing in ODAC.JS:

// route/www.js
Odac.Route.post('/contact', 'contact.send', {
  rateLimit: { max: 5, window: 60000 }
});

// route/websocket.js
Odac.Route.auth.ws('/live', async Odac => {
  const user = await Odac.Auth.user();

  Odac.ws.send({
    type: 'connected',
    user: user.name,
    ip: Odac.Request.ip,
    secure: Odac.Request.ssl
  });
});
// hook/auth.js
module.exports = {
  async login(Odac, { user }) {
    await Odac.DB.users.where('id', user.id).update({
      last_login_at: new Date(),
      last_login_ip: Odac.Request.ip
    });
  },

  async loginFailed(Odac, { identity, reason }) {
    await Odac.DB.login_audit.insert({
      email: identity.email,
      ip: Odac.Request.ip,
      reason,
      date: new Date()
    });
  }
};

Notice what is missing from those files. There are no req.socket.remoteAddress checks, no manual X-Forwarded-* header parsing, and no Unix socket setup boilerplate. You read Odac.Request.ip and Odac.Request.ssl, and ODAC.JS guarantees those values reflect the verified visitor rather than an intermediary or a forged header.

Turbo Mode: Bypassing the Kernel TCP Stack

On an ODAC server, apps running on a bridge network automatically receive an ODAC_PROXY_SOCKET environment variable pointing to a private Unix domain socket (such as /odac-proxy/http.sock). Starting in ODAC.JS v1.8.0, every worker in your application cluster serves traffic on that socket path alongside its standard TCP port (PORT, defaulting to 1071).

Both standard HTTP requests and WebSocket upgrades travel through that socket with the exact same routing table, middleware chain, and session handling. When the socket comes up successfully on an ODAC server, the cluster primary prints a single confirmation line at startup:

⚡ Turbo Mode ODAC Proxy → unix socket, TCP stack bypassed.

If you do not see that banner in your logs, your application is serving TCP only. More importantly, we refused to let a local socket path become a single point of failure:

  • TCP never turns off: The standard TCP port is always bound. If the proxy socket cannot be created (because of a read-only directory, a bad path, or another process owning the path), ODAC.JS logs the error and continues serving on TCP without crashing.
  • Per-request fallback: If the ODAC Proxy cannot send a request over the Unix socket, it seamlessly falls back to the app's TCP port.
  • Operator opt-out: Server operators can disable backend Unix sockets globally by setting ODAC_BACKEND_SOCKETS=off in the ODAC server environment, keeping apps on TCP only.
  • Zero manual setup: You never need to configure ODAC_PROXY_SOCKET in .env or open your own listener. Outside an ODAC server (such as local npx odac dev sessions or external hosting), leave it unset.

Diagram showing ODAC Proxy routing HTTP/2 and WebSocket traffic over /odac-proxy/http.sock to ODAC.JS Workers in Turbo Mode with TCP port 1071 fallback

Surviving Multi-Worker Linux Lifecycles

Binding a Unix domain socket in a single-process script is easy. Keeping a Unix domain socket reliable across a clustered Node.js application during container restarts, rolling deploys, and worker crashes on Linux is a completely different engineering problem.

If individual workers owned socket creation or cleanup, a draining or crashing worker could unlink the socket file right out from under its healthy sibling workers. Worse, naive cleanup logic during rapid container restarts runs straight into Linux inode reuse traps.

To eliminate these race conditions, ODAC.JS v1.8.0 enforces a strict cluster primary ownership model for the socket lifecycle:

  • Single owner for creation and cleanup: Only the cluster primary prepares the socket path before forking workers, passing the resolved path down via the fork environment. Workers accept connections on the shared listener, and never unlink the socket file when exiting or crashing.
  • Symlink and non-socket protection: Before clearing an old file left behind by an abruptly stopped container, the primary checks the path safely. Symlinks are unlinked as links without ever following them to an unintended target, and non-socket files are left untouched while the app safely falls back to TCP.
  • Active liveness probing before startup: A stale socket file from a crashed container looks identical on disk to an active socket owned by another live process. The primary probes the socket with a 1000ms timeout before removing it; if something answers, it refuses to steal the path and falls back to TCP.
  • Inode-safe graceful shutdown: Matching device and inode numbers during shutdown is not enough on Linux, because the kernel immediately recycles freed inode numbers for newly created files. During a graceful stop, the primary waits for all workers to drain and exit, then probes the socket path one last time. If a new instance is already answering at that path, the old primary leaves the socket intact.

Pipeline showing cluster primary socket ownership across Startup Probe, Worker Pool serving, and inode-safe Graceful Stop

Why Blindly Trusting Private Networks Is a Trap

Speed means nothing if a neighbour container can impersonate your users. Historically, many Node.js frameworks solved reverse-proxy headers with a blanket default: trust loopback and RFC 1918 private networks (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16).

That assumption breaks down in modern containerized deployments in two dangerous ways:

  1. Docker published ports: When traffic enters a standalone container through a published Docker port, the direct TCP peer address seen by Node.js is the private Docker bridge gateway. If the framework trusts private networks by default, any external internet client can send raw X-Odac-Connection-RemoteAddress or X-Odac-Connection-Ssl headers and spoof any IP address or fake an HTTPS connection.
  2. Shared bridge networks: On multi-tenant or multi-service hosts, a neighbour container on the same private bridge can reach your app's TCP port directly. Without cryptographic verification, that neighbour can forge visitor metadata to bypass Odac.Route rate limiters, poison audit logs in hook/auth.js, or abuse Host-derived links.

There is also a subtle Unix socket gotcha lurking for application developers: on a Unix domain socket, Node.js reports an empty req.socket.remoteAddress. A reset TCP socket also reports an empty remoteAddress. Inferring trust from a missing remote address would open a catastrophic bypass, which is why ODAC.JS tracks proxy-socket connections directly at the listener level and tells developers never to read req.socket.remoteAddress in app code.

Cryptographic Proof and the New Trust Hierarchy

In ODAC.JS v1.8.0, proxy headers are honoured only when they provably originate from the ODAC Proxy or from an explicit proxy you configured. Before any controller or middleware runs, ODAC.JS resolves Odac.Request.ip and Odac.Request.ssl, and strips X-Odac-Connection-RemoteAddress, X-Odac-Connection-Ssl, and X-Odac-Connection-Signature from req.headers so application code can never trust raw unverified headers.

Two signals always prove the ODAC Proxy, regardless of what request.trustedProxies contains in odac.json:

  1. The proxy Unix domain socket (ODAC_PROXY_SOCKET): Only the ODAC Proxy has access to this socket, so traffic arriving on the proxy socket listener is trusted by construction.
  2. A valid cryptographic signature (ODAC_PROXY_KEY): Over TCP (and for ODAC tunnels, where the server re-signs visitor metadata from ODAC Cloud), the proxy attaches X-Odac-Connection-Signature (t=...,v1=...). ODAC.JS verifies this HMAC-SHA256 signature using constant-time comparison across the timestamp, HTTP method, Host, URL, remote address, and SSL state, rejecting any signature older than 60 seconds.

When neither signal is present, trust depends on whether the app is running under ODAC (ODAC_APP=true) and whether request.trustedProxies is configured:

Environment request.trustedProxies Not Set request.trustedProxies Set
Under ODAC, with ODAC_PROXY_KEY Nobody else (unsigned private TCP traffic is rejected) The explicitly listed peers are trusted too
Under ODAC, without ODAC_PROXY_KEY Loopback and private networks (for older servers or containers awaiting restart) Exactly the listed peers
Standalone / Outside ODAC Nobody (all proxy connection headers ignored) Exactly the listed peers

Flow diagram showing ODAC_PROXY_SOCKET, ODAC_PROXY_KEY HMAC verification, and request.trustedProxies converging into Odac.Request.ip and Odac.Request.ssl

This strict verification protects more than just Odac.Request.ip logs. For example, passwordless authentication via Odac.Auth.magic() only falls back to the incoming Host header when neither url nor auth.magicLinkUrl is configured if the request provably arrived through the ODAC Proxy or a trusted proxy. Untrusted Host headers are rejected outright, preventing attackers from poisoning magic-link authentication URLs with their own domain.

Configuring Your Own Reverse Proxy

If you run ODAC.JS standalone on a VPS, in Docker outside an ODAC server, or behind your own Nginx or Caddy instance, zero-trust defaults mean no proxy headers are honoured out of the box.

To enable proxy metadata behind your own reverse proxy, declare its address or CIDR range in odac.json under request.trustedProxies:

{
  "request": {
    "timeout": 30000,
    "trustedProxies": ["loopback", "10.20.0.0/16"]
  }
}

Entries accept single IP addresses, CIDR ranges, or the built-in keywords "loopback" and "private". Passing an empty array [] disables TCP proxy trust completely while still preserving trust for the ODAC Proxy Unix socket and valid signatures if deployed on ODAC later.

Just as importantly, configure your reverse proxy to overwrite both X-Odac-Connection-RemoteAddress and X-Odac-Connection-Ssl rather than appending or passing client-supplied values through. In Nginx, for example:

proxy_set_header X-Odac-Connection-RemoteAddress $remote_addr;

Finally, resist the temptation to set ODAC_APP=true, ODAC_PROXY_SOCKET, or ODAC_PROXY_KEY manually in .env or your container manifest. Those variables belong exclusively to the ODAC server runtime. Keeping them untouched ensures local development (npx odac dev), standalone Docker builds, and production ODAC clusters all behave predictably.

Faster Transport, Stronger Guarantees

ODAC.JS v1.8.0 brings enterprise transport performance and cryptographic boundary enforcement together without adding a single configuration file to your project. When deployed on an ODAC server, your HTTP routes and WebSocket handlers automatically upgrade to Unix socket Turbo Mode with non-fatal TCP fallback, while every visitor IP and TLS flag is backed by either listener isolation or a 60-second HMAC-SHA256 signature. Even outside ODAC, your containers are now protected against header spoofing and published-port impersonation by default.