Skip to content

Commit 2f2f485

Browse files
Copexitclaude
andcommitted
fix: relax nginx rate limit and address regex for Tor proxy
The Chainalysis check sends up to 20 sequential requests through the Tor proxy. The rate limit (1r/s burst=5) was rejecting requests beyond the burst, causing the "Tor proxy unavailable" fallback dialog. Fix: increase to 2r/s burst=25 to accommodate the full batch. Also fix the address regex in both the tor-proxy sidecar and Cloudflare Worker to accept testnet/signet addresses (tb1, m, n, 2 prefixes) in addition to mainnet (1, 3, bc1). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 3c01ec8 commit 2f2f485

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

umbrel/nginx.conf.template

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
# Rate limit for Tor proxy endpoint (1 req/sec per client IP, burst of 5)
2-
limit_req_zone $binary_remote_addr zone=tor_proxy:1m rate=1r/s;
1+
# Rate limit for Tor proxy endpoint (2 req/sec per client IP, burst of 25)
2+
# Must accommodate up to 20 sequential Chainalysis address checks
3+
limit_req_zone $binary_remote_addr zone=tor_proxy:1m rate=2r/s;
34

45
server {
56
listen 8080;
@@ -58,7 +59,7 @@ server {
5859

5960
# Reverse proxy: forward /tor-proxy/* to the Tor proxy sidecar
6061
location /tor-proxy/ {
61-
limit_req zone=tor_proxy burst=5 nodelay;
62+
limit_req zone=tor_proxy burst=25 nodelay;
6263
proxy_pass http://${APP_TOR_PROXY_IP}:${APP_TOR_PROXY_PORT}/;
6364
proxy_set_header Host $host;
6465
proxy_set_header X-Real-IP $remote_addr;

umbrel/tor-proxy/server.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ const agent = new SocksProxyAgent(
1414
`socks5h://${TOR_PROXY_IP}:${TOR_PROXY_PORT}`
1515
);
1616

17-
const ADDR_RE = /^\/chainalysis\/address\/([13][a-km-zA-HJ-NP-Z1-9]{25,34}|bc1[qpzry9x8gf2tvdw0s3jn54khce6mua7l]{39,87})$/;
17+
// Supports mainnet (1/3/bc1), testnet/signet (m/n/2/tb1)
18+
const ADDR_RE = /^\/chainalysis\/address\/([13mn2][a-km-zA-HJ-NP-Z1-9]{25,34}|(bc1|tb1)[qpzry9x8gf2tvdw0s3jn54khce6mua7l]{39,87})$/;
1819
const REQUEST_TIMEOUT_MS = 30_000;
1920
const MAX_RESPONSE_BYTES = 1024 * 1024; // 1 MB limit to prevent memory exhaustion
2021

workers/chainalysis-proxy/worker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const handler = {
1414

1515
// Extract address from path: /address/{address}
1616
const url = new URL(request.url);
17-
const match = url.pathname.match(/^\/address\/([13][a-km-zA-HJ-NP-Z1-9]{25,34}|bc1[qpzry9x8gf2tvdw0s3jn54khce6mua7l]{39,87})$/);
17+
const match = url.pathname.match(/^\/address\/([13mn2][a-km-zA-HJ-NP-Z1-9]{25,34}|(bc1|tb1)[qpzry9x8gf2tvdw0s3jn54khce6mua7l]{39,87})$/);
1818
if (!match) {
1919
return new Response("Invalid path. Use /address/{btc_address}", {
2020
status: 400,

0 commit comments

Comments
 (0)