Overview
Theblock responder immediately blocks requests with a 403 Forbidden status code. This is the most straightforward way to deny access to specific IP ranges.
The
block responder requires no additional configuration beyond specifying the IP ranges.When to Use
Use theblock responder when:
- You want to explicitly deny access to certain IP ranges
- A clear 403 Forbidden response is acceptable
- You don’t need custom messages or status codes
- You want a simple, no-configuration solution
Configuration Examples
- Caddyfile
- JSON
Example 1: Block Specific IP Ranges
- The
203.0.113.0/24CIDR range - All OpenAI IP addresses (using the built-in
openairange) - The
198.51.100.0/24CIDR range
Example 2: Block Private Networks
- Blocks all private IP ranges (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16)
- Only serves content to public IP addresses
- Useful for preventing internal network access
Response Behavior
When a request is blocked:- HTTP status code: 403 Forbidden
- Response body: Default Caddy 403 error page
- Connection: Closed after response is sent
For custom error messages or status codes, use the custom responder instead.