Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Reverse Proxy (nginx / Caddy)

The daemon serves its HTTP API + UI on status_listen (default :18334) as plain HTTP. For a public or friends pool you usually want it behind a reverse proxy that terminates TLS (HTTPS) on port 443, so miners and the dashboard reach it over an encrypted, named endpoint (https://pool.example.com).

You have two ways to get HTTPS — pick one:

  1. Built-in TLS — set status_tls_listen (and provide a cert) and the daemon serves HTTPS directly. Simplest; no extra software. See Configuration Reference.
  2. Reverse proxy (this page) — an established web front (nginx / Caddy) does TLS, HTTP/2, automatic certificate renewal, access logs and its own rate-limit, forwarding to the daemon over loopback. This is the recommended setup once the pool is internet-facing.

Stratum is not HTTP. Only the API/UI (:18334) goes through an HTTP reverse proxy. The Stratum endpoints — plain :3333, TLS :3334, and Stratum V2 on its own sv2_listen port (the reference deployment uses :3336, NOISE NX handshake) — are raw TCP protocols. Expose those ports directly (or through an L4/TCP load balancer such as nginx stream {} or HAProxy TCP mode), never through an HTTP server {} / reverse_proxy block.

Two settings that matter behind a proxy

When the daemon runs behind a proxy, set both of these in config.toml under [server]:

[server]
# The proxy now sees the real client; the daemon only sees the proxy's loopback
# address. Setting this true makes the daemon trust the proxy's X-Forwarded-For
# header for the real client IP — used by the audit log and the login throttle
# (the Stratum ban list works on TCP peers and never sees HTTP headers; the
# API rate limit keys on the TCP peer too). See the warning below.
trust_proxy_headers = true

# The login cookie is only sent over HTTPS. Set true whenever the UI is reached
# via https:// (i.e. always, behind a TLS-terminating proxy).
cookie_secure = true

⚠️ Only set trust_proxy_headers = true behind a proxy you control. If the daemon is reachable directly from the internet with this on, any client can forge X-Forwarded-For and spoof its IP into your audit log and past the login throttle. Bind status_listen to loopback (127.0.0.1:18334) so only the proxy can reach it (in Docker: keep :18334 and publish the port on the host’s loopback, -p 127.0.0.1:18334:18334). And have the proxy replace the header rather than append to it: the daemon reads the first address in the list, so an appending proxy ($proxy_add_x_forwarded_for, Caddy’s default) would pass a client-supplied value through. The examples below set it to the peer address. See Security.

Stratum behind an L4 balancer: PROXY protocol (v1.45)

When the Stratum ports sit behind HAProxy or nginx stream {}, every miner reaches the daemon from the balancer’s address: the connect rate limit, the auto-bans, max_connections_per_ip, the worker’s IP on the Workers page and the logs all see one IP, and one misbehaving miner can get the whole balancer banned. The fix is the PROXY protocol: the balancer prefixes each connection with the real client address (v1 text or v2 binary, as HAProxy and nginx send it), and the daemon uses that address everywhere a peer address is used — on the V1 plain, V1 TLS and Sv2 listeners alike.

[server]
pool_listen = "127.0.0.1:13333"          # daemon on internal ports; the balancer owns 3333/3334/3336
[stratum]
stratum_tls_listen = "127.0.0.1:13334"
sv2_listen = "127.0.0.1:13336"
proxy_protocol = true
proxy_protocol_trusted = ["127.0.0.1", "10.0.0.0/8"]   # the balancer(s), CIDR or IP

With the balancer on the same host, move the daemon to internal ports as above (or bind the balancer to the public address only): two listeners on *:3333 would fail with EADDRINUSE. And note what the trust list means: every connection from a trusted address must carry the header, so with 127.0.0.1 in the list a translator sidecar, a local miner or a probe that connects to the daemon’s ports directly from the same host is dropped — point those at the balancer, or give the daemon ports to the balancer only and list the balancer’s own address instead of loopback.

The header is read only from peers in proxy_protocol_trusted, and those peers must send it — a trusted source that starts with Stratum JSON or a NOISE handshake instead, or sends a malformed header, is dropped (a balancer that lost its send-proxy would otherwise feed its first bytes to the Stratum parser; the daemon log says trusted PROXY-protocol source sent no valid header). Connections from any other address are never parsed, so nobody can spoof a client address from outside. PROXY UNKNOWN (v1) and LOCAL (v2 health checks) keep the TCP peer. The header must arrive within 5 s.

HAProxy (TCP mode, v2 header; use send-proxy for v1):

listen stratum
    bind *:3333
    mode tcp
    server pool 127.0.0.1:13333 send-proxy-v2
listen stratum-tls
    bind *:3334
    mode tcp
    server pool 127.0.0.1:13334 send-proxy-v2
listen stratum-v2
    bind *:3336
    mode tcp
    server pool 127.0.0.1:13336 send-proxy-v2

nginx stream {}:

stream {
    server {
        listen 3333;
        proxy_pass 127.0.0.1:13333;
        proxy_protocol on;
    }
}

List the balancer’s address or subnet when it runs on another host, and bind the daemon’s Stratum ports so that only the balancer can reach them. Rate limits, bans (dvb-warppool-cli / Admin → Rate limit), the per-IP cap, /api/workers and the Sv2 handshake logs then show the miner, not the balancer.

One upstream with the single port

With [stratum] single_port = true (see the Configuration Reference) the plain Stratum port takes V1, V1 over TLS and Stratum V2, so the balancer can forward one public port to one upstream instead of three:

[server]
pool_listen = "127.0.0.1:13333"
[stratum]
single_port = true
stratum_tls_listen = "127.0.0.1:13334"   # still needed: it is what configures TLS
sv2_listen = "127.0.0.1:13336"           # … and Stratum V2
proxy_protocol = true
proxy_protocol_trusted = ["127.0.0.1"]

The balancer sends the PROXY header (v1 or v2) as before; the daemon reads it first, then looks at the miner’s own first bytes to tell the protocol, and the real client address reaches whichever server takes the connection. TLS still ends in the daemon: the balancer passes the bytes through (L4); it must not terminate TLS on that port.

Public wallet pages (/users/<address>)

A per-worker 0% pool exposes a login-free page per miner at /users/<address>, with ckpool-compatible JSON at /api/users/<address> for firmware and ckstats. Both are ordinary HTTP on the same status port as the dashboard, so the catch-all location / (nginx) / reverse_proxy (Caddy) below already forwards them — no per-route config needed (unlike /api/events, they are plain request/response, no buffering tweaks). Just confirm they answer through the proxy: curl https://pool.example.com/api/users/<some-address> should return the ckpool-style JSON, and https://pool.example.com/users/<address> should load the wallet page.

Server-Sent Events (/api/events)

The dashboard’s live updates (block-found, new-job, …) use a long-lived Server-Sent-Events stream at GET /api/events. A proxy that buffers responses or times the connection out will break live push. Both examples below disable response buffering and raise the read timeout for that path.

Caddy

Caddy gets you automatic HTTPS (Let’s Encrypt) with almost no config:

pool.example.com {
    reverse_proxy 127.0.0.1:18334 {
        # SSE: stream the response, don't buffer it.
        flush_interval -1
    }
}

That’s the whole file. Caddy fetches and renews the certificate, terminates TLS, forwards X-Forwarded-For / X-Forwarded-Proto automatically (add header_up X-Forwarded-For {remote_host} inside reverse_proxy so a client-supplied header is replaced, not appended to), and flush_interval -1 keeps /api/events flowing.

nginx

server {
    listen 443 ssl http2;
    server_name pool.example.com;

    ssl_certificate     /etc/letsencrypt/live/pool.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/pool.example.com/privkey.pem;

    # Dashboard, API, and the public wallet pages (/users/<address> +
    # ckpool-compatible /api/users/<address> JSON) — all plain HTTP, no
    # per-route tuning needed.
    location / {
        proxy_pass http://127.0.0.1:18334;
        proxy_http_version 1.1;
        proxy_set_header Host              $host;
        proxy_set_header X-Forwarded-For   $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;
    }

    # Server-Sent-Events stream: no buffering, long-lived connection.
    location /api/events {
        proxy_pass http://127.0.0.1:18334;
        proxy_http_version 1.1;
        proxy_set_header Host              $host;
        proxy_set_header X-Forwarded-For   $remote_addr;
        proxy_set_header Connection        '';
        proxy_buffering off;
        proxy_cache off;
        proxy_read_timeout 1h;
    }
}

# Redirect plain HTTP → HTTPS
server {
    listen 80;
    server_name pool.example.com;
    return 301 https://$host$request_uri;
}

Use certbot (certbot --nginx -d pool.example.com) for the certificate.

Checklist

  • status_listen = "127.0.0.1:18334" — daemon only reachable via the proxy. Docker: keep status_listen = ":18334" and limit exposure with the port mapping instead (-p 127.0.0.1:18334:18334). Since v1.51 the image takes the listen addresses from config.toml; a loopback address there would be loopback inside the container, out of the proxy’s reach.
  • trust_proxy_headers = true and cookie_secure = true in [server].
  • /api/events is proxied without buffering (Caddy flush_interval -1 / nginx proxy_buffering off).
  • Public wallet pages reachable through the proxy: /users/<address> loads and /api/users/<address> returns JSON (per-worker pools only; served by the catch-all block, no special config).
  • Stratum ports (:3333 plain, :3334 TLS, sv2_listen e.g. :3336) exposed directly, not via the HTTP proxy — or through an L4 balancer with the PROXY protocol ([stratum] proxy_protocol, see above).
  • After changing [server], restart the daemon.