mirror of
https://github.com/fabriziosalmi/caddy-waf.git
synced 2025-12-23 22:27:46 -05:00
60 lines
2.3 KiB
Markdown
60 lines
2.3 KiB
Markdown
# Installation
|
|
|
|
## Quick Start
|
|
|
|
```bash
|
|
curl -fsSL -H "Pragma: no-cache" https://raw.githubusercontent.com/fabriziosalmi/caddy-waf/refs/heads/main/install.sh | bash
|
|
```
|
|
|
|
**Example Output:**
|
|
|
|
```
|
|
INFO Provisioning WAF middleware {"log_level": "info", "log_path": "debug.json", "log_json": true, "anomaly_threshold": 10}
|
|
INFO http.handlers.waf Updated Tor exit nodes in IP blacklist {"count": 1077}
|
|
INFO WAF middleware version {"version": "v0.0.0-20250115164938-7f35253f2ffc"}
|
|
INFO Rate limit configuration {"requests": 100, "window": 10, "cleanup_interval": 300, "paths": ["/api/v1/.*", "/admin/.*"], "match_all_paths": false}
|
|
WARN GeoIP database not found. Country blocking/whitelisting will be disabled {"path": "GeoLite2-Country.mmdb"}
|
|
INFO IP blacklist loaded successfully {"file": "ip_blacklist.txt", "valid_entries": 3, "total_lines": 3}
|
|
INFO DNS blacklist loaded successfully {"file": "dns_blacklist.txt", "valid_entries": 2, "total_lines": 2}
|
|
INFO Rules loaded {"file": "rules.json", "total_rules": 70, "invalid_rules": 0}
|
|
INFO WAF middleware provisioned successfully
|
|
```
|
|
|
|
## Step by step installation
|
|
|
|
```bash
|
|
# Step 1: Clone the caddy-waf repository from GitHub
|
|
git clone https://github.com/fabriziosalmi/caddy-waf.git
|
|
|
|
# Step 2: Navigate into the caddy-waf directory
|
|
cd caddy-waf
|
|
|
|
# Step 3: Clean up and update the go.mod file
|
|
go mod tidy
|
|
|
|
# Step 4: Fetch and install the required Go modules
|
|
go get github.com/caddyserver/caddy/v2
|
|
go get github.com/caddyserver/caddy/v2/caddyconfig/caddyfile
|
|
go get github.com/caddyserver/caddy/v2/caddyconfig/httpcaddyfile
|
|
go get github.com/caddyserver/caddy/v2/modules/caddyhttp
|
|
go get github.com/oschwald/maxminddb-golang
|
|
go get github.com/fsnotify/fsnotify
|
|
go get -v github.com/fabriziosalmi/caddy-waf
|
|
go mod tidy
|
|
|
|
# Step 5: Download the GeoLite2 Country database (required for country blocking/whitelisting)
|
|
wget https://git.io/GeoLite2-Country.mmdb
|
|
|
|
# Step 6: Build Caddy with the caddy-waf module
|
|
xcaddy build --with github.com/fabriziosalmi/caddy-waf=./
|
|
|
|
# Step 7: Fix Caddyfile format
|
|
caddy fmt --overwrite
|
|
|
|
# Step 8: Run the compiled Caddy server
|
|
./caddy run
|
|
```
|
|
|
|
Go to the [configuration](https://github.com/fabriziosalmi/caddy-waf/blob/main/docs/configuration.md) documentation section.
|
|
|