Why Advanced Builds?
By default, Caddy Defender includes IP ranges for major cloud providers and AI services. However, some features require build-time configuration:- Tor exit nodes: Dynamic list of Tor network exit points
- ASN filtering: Block entire Autonomous System Numbers (ISPs, hosting providers)
- They can significantly increase binary size
- They require user-specific configuration (ASN numbers)
- They may impact build time
Build-Time IP Range Fetchers
Caddy Defender uses a Go program atranges/main.go to fetch and embed IP ranges at build time. This ensures fast runtime performance without external API calls.
Available Fetchers
Tor Exit Nodes
Block traffic from Tor network exit points
ASN Ranges
Block entire autonomous systems by ASN number
Building with Tor Support
Run IP Range Generator with Tor
Execute the range generator with the This regenerates
--fetch-tor flag:ranges/data/generated.go with Tor exit node IP ranges included under the tor key.The Tor fetcher converts individual node IPs to IP ranges for efficient storage and lookup.
Build with xcaddy
Build the Caddy binary with your custom-generated data:The
$(pwd) tells xcaddy to use your local copy with the regenerated IP ranges.Building with ASN Support
ASN (Autonomous System Number) filtering allows you to block entire networks operated by specific organizations.Identify Target ASNs
Determine which ASNs you want to block. Common examples:
- AS15169: Google
- AS13335: Cloudflare
- AS16509: Amazon AWS
- AS8075: Microsoft
- AS14061: DigitalOcean
Run Generator with ASN List
Use the This adds IP ranges for Google and Cloudflare to the
--asn flag with a comma-separated list of ASNs:asn key in the generated data.Combining Multiple Fetchers
You can enable both Tor and ASN fetchers in a single build:tor and asn keys available:
Building with Docker
For production deployments, build a custom Docker image with your desired fetchers:Generator Command Reference
Theranges/main.go program supports several flags:
| Flag | Description | Example |
|---|---|---|
--fetch-tor | Enable Tor exit node fetching | --fetch-tor |
--asn | Comma-separated ASN list | --asn "AS15169,AS13335" |
--format | Output format (go or json) | --format json |
--output | Output file path | --output custom.go |
Output Formats
Go format (default):ranges/data/generated.go for embedding in the binary.
JSON format:
Performance Considerations
Binary Size Impact
- Standard build: ~45-50 MB
- With Tor: +5-10 MB
- With ASN (5 ASNs): +2-5 MB per ASN
- With both: Varies based on ASN count
Build Time Impact
- Standard build: 1-2 minutes
- With Tor: +30-60 seconds (fetching exit node list)
- With ASN: +10-30 seconds per ASN (fetching BGP data)
Runtime Performance
Runtime performance is not affected by additional IP ranges. All lookups use the high-performance BART (Balanced ART) data structure, maintaining O(log n) complexity regardless of range count.
When to Use Advanced Builds
Use Tor Blocking When:
- You need to prevent anonymous access
- Your service is targeted by Tor-based scrapers
- Compliance requires blocking anonymizing networks
- You operate a regional service with geo-restrictions
Use ASN Blocking When:
- You want to block entire hosting providers
- You need to prevent datacenter-based scraping
- You have specific ASN-based threat intelligence
- You want granular control over cloud provider access
Skip Advanced Builds If:
- You only need to block major AI services (use default build)
- Binary size is a critical constraint
- You need fast CI/CD build times
- You prefer runtime-configurable IP lists
Updating IP Ranges
IP ranges change over time. To update:Troubleshooting
Generator Fails to Fetch Data
If the range generator fails:Invalid ASN Format
ASNs must be prefixed with “AS”:Generated File Not Found
Ensure you’re building from the repository root:Next Steps
Configuration
Learn how to configure the Defender plugin
Examples
See real-world configuration examples