diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2026-01-14 11:42:05 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2026-01-14 13:40:03 +0000 |
| commit | 50000cd9d47681390c3c45feef98fe51c7b79a0f (patch) | |
| tree | 53ede8cb63ac2c5fe2321a6ecd9c87956537bbc7 /docs/reference/configuration.md | |
| parent | e3792b9abefd43b4594af2640ad4665c006fa3b0 (diff) | |
Add explicit rate limits and total connection limit
- Make RateLimit explicit in relay builder (500 subs, 60 events/min)
- Add NGIT_MAX_CONNECTIONS config option (default: 500)
- Update all 4 config locations (src, nix, docs, .env.example)
- Fix documentation error: filter limit 5000→500
- Document Phase 2 deferral decision (per-IP enforcement)
Addresses primary DoS vector (connection exhaustion) with minimal code.
Per-IP rate limiting deferred until abuse detected in production.
Related: issue ff38 (git endpoint throttling - separate concern)
Diffstat (limited to 'docs/reference/configuration.md')
| -rw-r--r-- | docs/reference/configuration.md | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/docs/reference/configuration.md b/docs/reference/configuration.md index 8b49297..c3001d3 100644 --- a/docs/reference/configuration.md +++ b/docs/reference/configuration.md | |||
| @@ -925,6 +925,46 @@ Event blacklist does **not** affect NIP-11 metadata: | |||
| 925 | 925 | ||
| 926 | --- | 926 | --- |
| 927 | 927 | ||
| 928 | ### Rate Limiting & DoS Protection | ||
| 929 | |||
| 930 | #### `NGIT_MAX_CONNECTIONS` | ||
| 931 | |||
| 932 | **Description:** Maximum total connections to the relay. Prevents connection exhaustion DoS attacks. | ||
| 933 | **Type:** Integer | ||
| 934 | **Default:** `500` | ||
| 935 | **Required:** No | ||
| 936 | |||
| 937 | **Examples:** | ||
| 938 | |||
| 939 | ```bash | ||
| 940 | # Default: 500 connections | ||
| 941 | NGIT_MAX_CONNECTIONS=500 | ||
| 942 | |||
| 943 | # Higher limit for large public relay | ||
| 944 | NGIT_MAX_CONNECTIONS=1000 | ||
| 945 | |||
| 946 | # Lower limit for private relay | ||
| 947 | NGIT_MAX_CONNECTIONS=100 | ||
| 948 | ``` | ||
| 949 | |||
| 950 | **Notes:** | ||
| 951 | |||
| 952 | - Limits total concurrent WebSocket connections to the relay | ||
| 953 | - Prevents connection exhaustion attacks | ||
| 954 | - Works in conjunction with per-connection limits (500 subscriptions, 60 events/min) | ||
| 955 | - When limit is reached, new connections are rejected | ||
| 956 | - Existing connections continue to work normally | ||
| 957 | |||
| 958 | **Related Limits:** | ||
| 959 | |||
| 960 | Per-connection limits (built-in to relay-builder, not configurable): | ||
| 961 | - Max subscriptions per connection: 500 | ||
| 962 | - Max events per minute per connection: 60 | ||
| 963 | - Max subscription ID length: 250 characters | ||
| 964 | - Max results per filter: 500 | ||
| 965 | |||
| 966 | --- | ||
| 967 | |||
| 928 | ### Logging Configuration | 968 | ### Logging Configuration |
| 929 | 969 | ||
| 930 | #### `RUST_LOG` | 970 | #### `RUST_LOG` |