Caddy Defender is a powerful middleware plugin for Caddy that enables the blocking and manipulation of requests based on client IP addresses. It helps prevent unwanted traffic and protects your website's data from being used in AI training through customizable responses, ensuring your web experience remains secure and reliable.
The Caddy Defender Plugin serves as an effective middleware solution for the Caddy web server, enabling users to block or manage requests based on client IP addresses. This feature is particularly valuable for preventing unwanted bot traffic and protecting website data from being used for AI training, by returning non-informative or corrupted responses.
403 Forbidden response to the request.The Caddyfile directive provides a simple syntax to set up the defender plugin, optimizing control over traffic management.
defender <responder> {
message <custom message>
range <ip_ranges...>
}
Where:
<responder> expresses the action to take, with options such as block, garbage, or custom.<ip_ranges...> includes CIDR ranges or predefined keys (e.g., openai).<custom message> specifies any returned message when using the custom responder.To block requests from certain IP ranges:
localhost:8080 {
defender block {
range 203.0.113.0/24 openai 198.51.100.0/24
}
respond "Hello, world!" # Response for users
}
To return corrupted responses for specific IP ranges:
localhost:8081 {
defender garbage {
range 192.168.0.0/24
}
respond "Hello, world!" # Response for users
}
To provide a custom message for requests from designated IP ranges:
localhost:8082 {
defender custom {
message "Custom response message"
range 10.0.0.0/8
}
respond "Hello, world!" # Response for users
}
The plugin incorporates predefined IP ranges for several prominent AI services, allowing users to employ them without additional configuration:
| Service | IP Ranges |
|---|---|
| OpenAI | openai.go |
| DeepSeek | deepseek.go |
| GitHub Copilot | github.go |
| Microsoft Azure | azure.go |
| Localhost (testing) | localhost.go |
| AWS | aws.go |
| AWS Region | aws_region.go |
Contributions are welcomed. Those interested in adding new IP ranges or responder functionalities can find more information in the Contributing Guide.
Inspired by discussions within the community, this project is built on top of the well-regarded Caddy. For those interested in observing the project's growth, please view the Star History.
No comments yet.
Sign in to be the first to comment.