Repository navigation
Howto Tune difficulty and clearance lifetime
Two numbers set the price of your site: how much work one clearance costs, and how long it lasts.
pow_gate_difficulty N is the expected number of hashes per solve. Cost is
linear in N — for the attacker and for the honest visitor alike.
N |
Typical wait on a laptop | Use when |
|---|---|---|
50000 (default) |
imperceptible | light deterrence only |
500000 |
~0.1–0.5 s | sensible starting point |
2000000 |
~0.5–2 s | active scraping, some human delay is acceptable |
10000000+ |
several seconds | targeted abuse; slow devices will complain |
The solver hashes on all cores through Web Workers. A low-end phone is roughly
ten times slower than a laptop, so test your choice on the slowest device you
care about. The compiled-in default of 50000 is low for the current solver —
set the value explicitly.
Raise the price for suspicious clients only, instead of for everyone: Block or slow down crawlers.
$pow_gate_load is the one-minute load average as a percentage of the CPUs
(100 = all busy). Map it to a multiplier:
map $pow_gate_load $pow_scale {
default 1;
~^(1[5-9]\d|2\d\d)$ 2; # 150–299 %
"~^([3-9]\d\d|\d{4,})$" 4; # 300 % and up
}
location / {
pow_gate on;
pow_gate_difficulty 500000;
pow_gate_difficulty_scale $pow_scale;
}The multiplier applies to new challenges only. Visitors who are already cleared are not challenged again when load rises. A complete include is in examples/load-adaptive.conf.
A Content-Security-Policy that does not allow worker-src 'self' stops the
solver from starting workers. It still works, on one core. The browser console
shows the CSP violation.
pow_gate_clearance_ttl (default 12h) is how long one solve lasts.
- Shorter: a scraper pays more often — and so do your visitors.
- Longer: fewer challenges, and a longer free ride after one solve.
Lowering the value also shortens clearances that were already issued.
A clearance is bound to the exact client address, the User-Agent and the policy. A visitor whose address changes solves again. If your audience moves between addresses a lot — mobile networks, IPv6 privacy addresses — widen the binding:
pow_gate_ipv6_prefix 64; # default 128
pow_gate_ipv4_prefix 32; # default 32Everyone inside the prefix then shares the same address binding, so do not go wider than you need. Changing a prefix renames the cookie; clients solve once more.
- Change
pow_gate_policy <name>to drop the clearances of that scope. - Replace the HMAC key to drop all of them.
Log $pow_gate_result and $pow_gate_difficulty
(Read the gate logs) and compare issued
(challenges fetched) with accepted (challenges solved). Many fetched and few
solved means clients give up or run out of time — on real browsers, a sign the
difficulty is too high for their devices.
Reference: configuration.md › Tuning.
Getting started
Policy
- Let verified search engines through
- Block or slow down crawlers
- Tune difficulty and clearance lifetime
- Exclude paths and APIs
- Use the bundled rules
- Keep link previews working
Deployment
Operations