Caddy Defender is a powerful middleware plugin for Caddy that enables intelligent control over incoming traffic. By blocking or manipulating requests based on IP addresses, it prevents unwanted traffic and safeguards your website's data from being used in AI training. With customizable options and easy integration, it enhances website security effortlessly.
The Caddy Defender plugin serves as an essential middleware for the Caddy web server, designed to enhance security by allowing users to block or manipulate incoming requests based on their client's IP address. This functionality is particularly beneficial in mitigating unwanted traffic and safeguarding against the use of website data for AI training purposes by returning disruptive responses.
403 Forbidden response to denied requests.The defender directive allows for straightforward configuration in the Caddyfile:
defender <responder> {
message <custom message>
range <ip_ranges...>
}
To block requests from specific IP address ranges:
localhost:8080 {
defender block {
range 203.0.113.0/24 openai 198.51.100.0/24
}
respond "Hello, world!" # what humans see
}
To return garbage data for requests from certain IP ranges:
localhost:8081 {
defender garbage {
range 192.168.0.0/24
}
respond "Hello, world!" # what humans see
}
To return a custom message for specific IP ranges:
localhost:8082 {
defender custom {
message "Custom response message"
range 10.0.0.0/8
}
respond "Hello, world!" # what humans see
}
The plugin comes with predefined embedded IP ranges for popular AI services, facilitating instant usage without extra setup. Key services include:
| 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 to enhance the plugin are encouraged. Options include:
ranges/fetchers package as detailed in the Contributing Guide.responders package, updating the UnmarshalCaddyfile method to accommodate this addition by following guidelines in the Contributing Guide.This project drew inspiration from community discussions and is built with care using the Caddy platform.
No comments yet.
Sign in to be the first to comment.