Overview
Theratelimit responder marks requests from specific IP ranges for rate limiting, integrating seamlessly with the caddy-ratelimit module. This allows you to apply different rate limits to different IP ranges.
The
ratelimit responder requires the caddy-ratelimit module to be installed and configured.When to Use
Use theratelimit responder when:
- You want to slow down, not block, specific IP ranges
- You need different rate limits for different traffic sources
- You want to throttle AI scrapers or bot traffic
- You want to protect APIs from abuse while allowing limited access
How It Works
- Caddy Defender marks requests from specified ranges
- The mark is detected by caddy-ratelimit via a header or matcher
- caddy-ratelimit applies the configured rate limit rules
- Requests exceeding the limit receive appropriate responses
Configuration Example
- Caddyfile
- JSON
- Marks requests from private IP ranges for rate limiting
- Applies a rate limit of 3 requests per minute
- Uses the remote host as the rate limit key
- Only applies to GET requests with the X-RateLimit-Apply header
Rate Limit Configuration
Therate_limit block supports several configuration options:
| Option | Description | Example |
|---|---|---|
zone | Named rate limit zone | zone api_limit { ... } |
match | Request matcher (method, header, path) | method GET |
key | What to rate limit by | {remote_host}, {http.request.header.API-Key} |
events | Number of allowed requests | 3, 100 |
window | Time window for the limit | 1m, 1h, 24h |
Real-World Examples
Rate Limit Keys
You can rate limit based on different request attributes:Advanced Integration
For complete rate limiting documentation, see the Rate Limiting Configuration and caddy-ratelimit documentation.