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
| `mode` | `string` | `prefix` | Must be: `prefix`, `suffix`, `regex`. Matching does not include query parameters. `excludeRoutes` always uses `prefix` except when `mode: regex`. Only use `regex` when needed |
100
106
| `protectRoutes` | `[]string` (required) | `""` | Comma-separated list of route prefixes/suffixes/regex patterns to protect. |
101
107
| `excludeRoutes` | `[]string` | `""` | Comma-separated list of route prefixes to **never** protect. e.g., `protectRoutes: "/"` protects the entire site. `excludeRoutes: "/ajax"` would never challenge any route starting with `/ajax` |
102
-
| `captchaProvider` | `string` (required) | `""` | The captcha type to use. Supported values: `turnstile`, `hcaptcha`, and `recaptcha`. |
108
+
| `captchaProvider` | `string` (required) | `""` | The captcha type to use. Supported values: `turnstile`, `hcaptcha`, `recaptcha`, and `poj` (proof-of-javascript). |
103
109
| `siteKey` | `string` (required) | `""` | The captcha site key. |
| `periodSeconds` | `int` | `0` | Health check interval (in seconds) for the primary captcha provider. The circuit breaker uses this to detect provider outages. |
112
+
| `failureThreshold` | `int` | `0` | Number of consecutive health check failures before the circuit breaker opens and switches to proof-of-javascript fallback. |
105
113
| `rateLimit` | `uint` | `20` | Maximum requests allowed from a subnet before a challenge is triggered. |
106
114
| `window` | `int` | `86400` | Duration (in seconds) for monitoring requests per subnet. |
107
115
| `ipv4subnetMask` | `int` | `16` | CIDR subnet mask to group IPv4 addresses for rate limiting. |
@@ -122,6 +130,24 @@ services:
122
130
| `persistentStateFile` | `string` | `""` | File path to persist rate limiter state across Traefik restarts. In Docker, mount this file from the host. |
123
131
| `enableStateReconciliation` | `string` | `"false"` | When `"true"`, reads and merges disk state before each save to prevent multiple instances from overwriting data. Adds extra I/O overhead. Only enable for multi-instance deployments sharing state. **Performance warning**: Not recommended for sites with >1M unique visitors due to reconciliation overhead (5-8s per cycle at scale). |
124
132
133
+
### Circuit Breaker (failover if a captcha provider is unavailable)
134
+
135
+
The circuit breaker provides automatic failover when the primary captcha provider (Turnstile, reCAPTCHA, or hCaptcha) becomes unavailable. When enabled, it:
136
+
137
+
1. **Enables a liveness probe on the captcha provider**: Periodically sends HEAD requests to the provider's JavaScript file (every `periodSeconds`, default 30s). Also records 5xx errors during server side validation.
138
+
2. **Detects failures**: Counts consecutive health check failures
139
+
3. **Opens circuit**: After `failureThreshold` consecutive failures (default 3), switches to proof-of-javascript fallback
140
+
4. **Falls back to PoJ**: Ensures user is loading javascript. Requires revalidating in 1hr
141
+
5. **Auto-recovery**: Automatically returns to primary provider when health checks succeed
142
+
143
+
**Proof-of-Javascript Fallback:**
144
+
- Requires browsers to submit a form
145
+
- Self-contained (no external dependencies)
146
+
147
+
**Configuration:**
148
+
- Circuit breaker is **enabled by default** with `periodSeconds: 30` and `failureThreshold: 3`
149
+
- To disable: set both `periodSeconds: 0` and `failureThreshold: 0`
150
+
- The `poj` provider can also be used directly as the primary provider (no circuit breaker needed)
0 commit comments