You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit c344cc5
Browse filesBrowse the repository at this point in the historyBrowse files
docs(dde): reverse-proxy production posture — five rules, verified nginx snippet, backups, ops never-do list
New §6 subsection in the boundary document: all three guards key on the
direct peer, so behind nginx/Caddy/Traefik the client-differentiated limits
belong at the proxy (the app must not read forwarded headers — that is
contract-tested), the app stays on the loopback bind, the allowlist pins the
proxy's source address as containment for a misexposed port, the in-process
limiter is resized as a backstop above the edge ceiling (never disabled), and
body caps stay aligned. nginx directives verified against the official
limit_req and core module docs. Backups: the endpoint is stateless — what
must be preserved is the proxy config and the submitter's own fixtures; a
restart resets rate budgets (bounded by the proxy backstop). The live API
reference page's limits note now points at the posture.
Generated with Codebuff 🤖
Co-Authored-By: Codebuff <noreply@codebuff.com>
Copy file name to clipboardExpand all lines: docs/DDE-API-REFERENCE.html
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -231,8 +231,8 @@ <h2 data-i18n="h_sdk"></h2>
231
231
pr_health_t:{en:"/health is always exempt",ar:"/health معفاة دائمًا"},
232
232
pr_health_d:{en:"A flood can never consume liveness budget — otherwise the attack itself would hide the symptoms.",
233
233
ar:"الفيضان لا يستطيع أبدًا حجز ميزانية الحيوية — وإلا صار الهجوم نفسه يخفي الأعراض."},
234
-
limits_note:{en:"Limits are in-memory and per-process: horizontally scaled deployments should front the endpoint with their own limiter. The allowlist keys on the direct peer — put your proxy's address on the list, never trust forwarded headers.",
235
-
ar:"الحدود في الذاكرة ولكل عملية: النشر الموسع أفقيًا يضع أمامه محدّده الخاص."},
234
+
limits_note:{en:"Limits are in-memory and per-process: horizontally scaled deployments should front the endpoint with their own limiter. The allowlist keys on the direct peer — put your proxy's address on the list, never trust forwarded headers. Deploying behind nginx/Caddy/Traefik? Read the reverse-proxy production posture in the boundary document — five rules, a verified nginx snippet, backup guidance, and the ops never-do list.",
235
+
ar:"الحدود في الذاكرة ولكل عملية: النشر الموسع أفقيًا يضع أمامه محدّده الخاص. القائمة المسموحة تعتمد العنوان المباشر — ضع عنوان الـproxy في القائمة، ولا توثق الترويسات المرسلة أبدًا. ستنشر خلف nginx/Caddy/Traefik؟ اقرأ وضعية الإنتاج خلف الوكيل العكسي في وثيقة الحد — خمس قواعد ومقتطف nginx موثق وإرشادات النسخ الاحتياطي وقائمة ممنوعات التشغيل."},
236
236
h_sdk:{en:"In-process SDK — same contract, no wire",ar:"SDK داخل العملية — نفس العقد بلا شبكة"},
237
237
sdk_intro:{en:"For platforms that prefer embedding: the same gate without the network hop.",
238
238
ar:"للمنصات التي تفضل التضمين: نفس البوابة بلا قفزة الشبكة."},
2. **Bind the app to loopback only.** The default `host: "127.0.0.1"` stays —
293
+
never `0.0.0.0` "behind a proxy": that recreates a public bind whose guards
294
+
key on the wrong peer. The app is reachable only through the proxy.
295
+
296
+
3. **Allowlist = pin the proxy's source address(es).** With the proxy on the
297
+
same host, `allowAddresses: ["127.0.0.1"]` means the app accepts traffic
298
+
from the proxy alone — a briefly misexposed port is still gated. On a
299
+
private network, list the proxy hosts' addresses. (They all share one
300
+
verdict: the proxy is the front door by design.)
301
+
302
+
4. **The in-process rate limiter becomes a backstop, not the primary limiter.**
303
+
Size it above the proxy's per-client ceiling (e.g. `rateLimit: {
304
+
windowMs: 60_000, max: 600 }`for a 10 r/s edge limit) so it only fires on
305
+
aggregate floods or a misconfigured proxy. Do**not** disable it
306
+
(`rateLimit: false`) unless something in front always limits — the
307
+
in-process budget is the last line of defense.
308
+
309
+
5.**Keep the body caps aligned.**`client_max_body_size` (or your proxy's
310
+
equivalent) ≤ the app's 1 MiB cap, so oversized bodies die at the edge and
311
+
the app's two-layer gate remains the truth for anything that slips through.
312
+
313
+
**Production settings at a glance:**
314
+
315
+
| Setting | Direct bind (default) | Behind a reverse proxy |
316
+
|---|---|---|
317
+
| `host` | `127.0.0.1` | `127.0.0.1` (proxy on same host) or a private interface — never `0.0.0.0` |
318
+
| `rateLimit` | `120/min` per real client | backstop per proxy, sized **above** the proxy's per-client ceiling (e.g. 600/min); primary limiting at the edge |
319
+
|`allowAddresses`| omit — the loopback bind *is* the guard | pin the proxy's source address(es) — containment for a misexposed port |
320
+
| body cap | 1 MiB (two layers) | 1 MiB, with the edge cap ≤ 1 MiB so oversize dies at the proxy |
321
+
| TLS | out of scope (loopback) | terminated at the proxy; the app speaks plain HTTP over loopback/private net |
322
+
323
+
**Backups and recovery.** The endpoint is stateless by design: no database, no
324
+
persisted fixtures, rate-limit state is per-process memory. There is nothing
325
+
to back up at the app layer. Back up instead: (1) the **reverse-proxy config**
326
+
— it carries the real client-identity and edge-limit policy, which is the part
327
+
that cannot be reconstructed from this repo; (2) any fixtures *you* submitted
328
+
are yours — the endpoint keeps nothing. A process restart resets rate budgets
329
+
(fail-safe: it briefly trusts more); behind the recommended proxy backstop
330
+
that window is bounded and invisible. Proxy upstream health checks should
331
+
target `/health` — it is exempt from the rate limiter and returns the boundary
332
+
banner; remember the exemption is per-endpoint: `/health` free does not mean
333
+
`/verify` free.
334
+
335
+
**Never do (ops edition):** bind `0.0.0.0` and rely on the app guards as if
336
+
the peer were the client · make the app read forwarded headers to "fix"
337
+
per-client limiting (the contract forbids it — the fix is at the proxy) ·
338
+
publish the app's port alongside the proxy's · point untrusted third parties
339
+
at the app behind the proxy: the proxy **is** the front door, and every app
340
+
side guard assumes the door is the proxy.
341
+
255
342
## 7. What this design deliberately does not do
256
343
257
344
- It does not judge who is right. Both positions survive verbatim.
0 commit comments