🇬🇧 English · 🇹🇷 Türkçe
Caddy + Coraza WAF + OWASP Core Rule Set: a memory-safe reverse proxy written in Go, with automatic HTTPS and a built-in web application firewall (WAF).
Built as a drop-in replacement for the Nginx + ModSecurity stack. Compatible with ModSecurity rules (SecLang), ships with OWASP CRS, and rules and settings can be supplied as external files.
import waf.caddy-ratelimit module included.linux/amd64, linux/arm64.| Component | Version |
|---|---|
| Caddy | 2.11.9 |
| coraza-caddy | 2.6.2 |
| Coraza | 3.8.1 |
| OWASP CRS | 4.25.0 |
| caddy-ratelimit | latest commit |
| Go | 1.27.4 |
| Alpine | 3.24 |
Exact versions in an image:
docker run --rm msecapps/caddy-coraza-waf cat /usr/share/caddy/versions.txt
| Tag | Description |
|---|---|
2.11.9-coraza2.6.2-crs4.25.0 | Immutable. Recommended for production. |
2.11.9 | Latest build of this Caddy version (rebuilt weekly) |
2.11 | Latest build of this minor version |
2, latest | Latest build |
Use the immutable tag in production. Test a new build in staging first, then bump the tag.
docker run -d --name caddy -p 80:80 -p 443:443 -p 443:443/udp msecapps/caddy-coraza-waf
The default site serves the welcome page on :80 with the WAF enabled. Test:
curl -s -o /dev/null -w '%{http_code}\n' http://localhost/ # 200
curl -s -o /dev/null -w '%{http_code}\n' "http://localhost/?id=1'%20OR%20'1'='1" # 403
services:
caddy:
image: msecapps/caddy-coraza-waf:2.11.9-coraza2.6.2-crs4.25.0
restart: unless-stopped
ports:
- "80:80"
- "443:443"
- "443:443/udp"
environment:
CORAZA_RULE_ENGINE: "On"
CORAZA_PARANOIA_LEVEL: "1"
CORAZA_ANOMALY_INBOUND: "5"
CORAZA_ANOMALY_OUTBOUND: "4"
volumes:
- ./sites:/etc/caddy/sites:ro
- ./global.d:/etc/caddy/global.d:ro
- ./coraza/before-crs:/etc/caddy/coraza/before-crs:ro
- ./coraza/after-crs:/etc/caddy/coraza/after-crs:ro
- caddy_data:/data # certificates: must be persistent
- caddy_config:/config
read_only: true
tmpfs:
- /tmp
cap_drop: [ALL]
cap_add: [NET_BIND_SERVICE]
security_opt:
- no-new-privileges:true
volumes:
caddy_data:
caddy_config:
./sites/app.caddy:
app.example.com {
import waf
reverse_proxy app:8080
}
That's it: the certificate is obtained automatically, HTTP is redirected to HTTPS, and requests pass through the WAF.
| Path | Contents |
|---|---|
/etc/caddy/sites/*.caddy | Sites. Use import waf where the WAF is wanted |
/etc/caddy/global.d/*.caddy | Global options (email, log, order, …), without braces |
/etc/caddy/coraza/before-crs/*.conf | Loaded before CRS: CRS settings, runtime exclusions with ctl:ruleRemoveById |
/etc/caddy/coraza/after-crs/*.conf | Loaded after CRS: SecRuleRemoveById, SecRuleUpdateTargetById, your own rules |
/etc/caddy/waf.caddy | The full waf snippet (for full control) |
/etc/caddy/Caddyfile | Main file (for full control) |
/data | Certificates and ACME accounts (persistent volume) |
/config | Caddy's autosaved configuration |
⚠️
coraza/before-crsandcoraza/after-crsmust contain at least one.conffile (it may be empty or comments only). Otherwise Coraza will not start.
| Variable | Default | Description |
|---|---|---|
CORAZA_RULE_ENGINE | On | On (block), DetectionOnly (log only), Off |
CORAZA_PARANOIA_LEVEL | 1 | CRS paranoia level (1–4). Higher means more protection and more false positives |
CORAZA_ANOMALY_INBOUND | 5 | Request blocking threshold. 5 = a single critical match blocks |
CORAZA_ANOMALY_OUTBOUND | 4 | Response blocking threshold |
CORAZA_AUDIT_ENGINE | RelevantOnly | Audit log: RelevantOnly, On, Off |
Quote
Onin YAML ("On"). Unquoted, some parsers read it astrue.
example.com {
handle /static/* {
root * /srv
file_server # no WAF
}
handle {
import waf
reverse_proxy app:8080
}
}
# global.d/order.caddy — run the rate limiter before the WAF
order rate_limit before coraza_waf
example.com {
handle /api/login {
rate_limit {
zone login {
key {remote_host}
events 10
window 1m
}
}
import waf
reverse_proxy app:8080
}
}
coraza/before-crs/10-exclusions.conf:
SecRule REQUEST_URI "@beginsWith /api/upload" \
"id:1000,phase:1,pass,nolog,ctl:ruleRemoveById=920420"
coraza/after-crs/10-custom.conf:
SecRuleRemoveById 942100
SecRule REQUEST_HEADERS:User-Agent "@contains sqlmap" \
"id:2000,phase:1,deny,status:403,log,msg:'Scanner blocked'"
example.com {
tls /certs/fullchain.pem /certs/privkey.pem
import waf
reverse_proxy app:8080
}
# global.d/dev.caddy — never contacts Let's Encrypt; all names use the local CA
local_certs
skip_install_trust
To make browsers trust it, export the root certificate and install it on your machine:
docker compose cp caddy:/data/caddy/pki/authorities/local/root.crt ./caddy-local-root.crt
The WAF audit log is written as JSON to stdout (docker logs). Only requests that match a rule or get blocked are recorded.
Most frequently triggered rules:
docker logs caddy 2>&1 | grep -oE '\[id \\"[0-9]+' | grep -oE '[0-9]+' | sort | uniq -c | sort -rn
Blocked requests:
docker logs caddy 2>&1 | grep 'Access denied'
Coraza's key not found in collection warnings are harmless. To hide them:
# global.d/log.caddy
log default {
exclude http.handlers.waf
}
docker exec caddy caddy validate --config /etc/caddy/Caddyfile
docker exec caddy caddy reload --config /etc/caddy/Caddyfile
If validate fails, reload is not applied and Caddy keeps running with the previous configuration.
CORAZA_RULE_ENGINE: "DetectionOnly" and watch normal traffic for a while."On". Prefer exclusions over raising the threshold.read_only, cap_drop: ALL + cap_add: NET_BIND_SERVICE and no-new-privileges is recommended.SecAuditLogParts ABHZ to keep request/response bodies out of the audit log (no passwords or personal data in logs).Apache-2.0. Bundled components are subject to their own licenses (Caddy, Coraza, coraza-caddy: Apache-2.0; OWASP CRS: Apache-2.0).
🇬🇧 English · 🇹🇷 Türkçe
Caddy + Coraza WAF + OWASP Core Rule Set: Go ile yazılmış, bellek güvenli, otomatik HTTPS'li ve web uygulama güvenlik duvarı (WAF) gömülü bir reverse proxy.
Nginx + ModSecurity yığınının yerine geçmek için hazırlandı. ModSecurity kurallarıyla (SecLang) uyumlu, OWASP CRS ile hazır geliyor, kurallar ve ayarlar dışarıdan dosya olarak verilebiliyor.
import waf ile istenen sitede açılır.caddy-ratelimit modülü dahil.linux/amd64, linux/arm64.| Bileşen | Sürüm |
|---|---|
| Caddy | 2.11.9 |
| coraza-caddy | 2.6.2 |
| Coraza | 3.8.1 |
| OWASP CRS | 4.25.0 |
| caddy-ratelimit | son commit |
| Go | 1.27.4 |
| Alpine | 3.24 |
Bir imajdaki tam sürümler:
docker run --rm msecapps/caddy-coraza-waf cat /usr/share/caddy/versions.txt
| Etiket | Açıklama |
|---|---|
2.11.9-coraza2.6.2-crs4.25.0 | Değişmez. Production için önerilir. |
2.11.9 | Bu Caddy sürümünün en son derlemesi (haftalık yenilenir) |
2.11 | Bu minor sürümün en son derlemesi |
2, latest | En son derleme |
Production'da değişmez etiketi kullanın. Yeni derlemeyi önce test ortamında deneyip sonra etiketi güncelleyin.
docker run -d --name caddy -p 80:80 -p 443:443 -p 443:443/udp msecapps/caddy-coraza-waf
Varsayılan site :80 üzerinde WAF açık olarak karşılama sayfasını sunar. Test:
curl -s -o /dev/null -w '%{http_code}\n' http://localhost/ # 200
curl -s -o /dev/null -w '%{http_code}\n' "http://localhost/?id=1'%20OR%20'1'='1" # 403
services:
caddy:
image: msecapps/caddy-coraza-waf:2.11.9-coraza2.6.2-crs4.25.0
restart: unless-stopped
ports:
- "80:80"
- "443:443"
- "443:443/udp"
environment:
CORAZA_RULE_ENGINE: "On"
CORAZA_PARANOIA_LEVEL: "1"
CORAZA_ANOMALY_INBOUND: "5"
CORAZA_ANOMALY_OUTBOUND: "4"
volumes:
- ./sites:/etc/caddy/sites:ro
- ./global.d:/etc/caddy/global.d:ro
- ./coraza/before-crs:/etc/caddy/coraza/before-crs:ro
- ./coraza/after-crs:/etc/caddy/coraza/after-crs:ro
- caddy_data:/data # sertifikalar: kalıcı olmalı
- caddy_config:/config
read_only: true
tmpfs:
- /tmp
cap_drop: [ALL]
cap_add: [NET_BIND_SERVICE]
security_opt:
- no-new-privileges:true
volumes:
caddy_data:
caddy_config:
./sites/app.caddy:
app.example.com {
import waf
reverse_proxy app:8080
}
Hepsi bu kadar: sertifika otomatik alınır, HTTP → HTTPS yönlendirmesi yapılır, istekler WAF'tan geçer.
| Yol | İçerik |
|---|---|
/etc/caddy/sites/*.caddy | Siteler. WAF istenen sitede import waf |
/etc/caddy/global.d/*.caddy | Global seçenekler (email, log, order, …), süslü parantezsiz |
/etc/caddy/coraza/before-crs/*.conf | CRS'ten önce: CRS ayarları, ctl:ruleRemoveById ile çalışma zamanı istisnaları |
/etc/caddy/coraza/after-crs/*.conf | CRS'ten sonra: SecRuleRemoveById, SecRuleUpdateTargetById, kendi kurallarınız |
/etc/caddy/waf.caddy | waf snippet'inin tamamı (tam kontrol için) |
/etc/caddy/Caddyfile | Ana dosya (tam kontrol için) |
/data | Sertifikalar ve ACME hesapları (kalıcı volume) |
/config | Caddy'nin otomatik kaydettiği yapılandırma |
⚠️
coraza/before-crsvecoraza/after-crsdizinlerinde en az bir.confdosyası bulunmalıdır (boş ya da yalnızca yorum içerebilir). Aksi halde Coraza başlamaz.
| Değişken | Varsayılan | Açıklama |
|---|---|---|
CORAZA_RULE_ENGINE | On | On (engelle), DetectionOnly (yalnızca logla), Off |
CORAZA_PARANOIA_LEVEL | 1 | CRS paranoia seviyesi (1–4). Yükseldikçe koruma ve yanlış alarm artar |
CORAZA_ANOMALY_INBOUND | 5 | İstek engelleme eşiği. 5 = tek kritik eşleşme engeller |
CORAZA_ANOMALY_OUTBOUND | 4 | Yanıt engelleme eşiği |
CORAZA_AUDIT_ENGINE | RelevantOnly | Audit log: RelevantOnly, On, Off |
YAML'da
Ondeğerini tırnak içinde yazın ("On"). Tırnaksız değer bazı ayrıştırıcılardatrueolarak okunur.
example.com {
handle /static/* {
root * /srv
file_server # WAF yok
}
handle {
import waf
reverse_proxy app:8080
}
}
# global.d/order.caddy — hız sınırı WAF'tan önce çalışsın
order rate_limit before coraza_waf
example.com {
handle /api/login {
rate_limit {
zone login {
key {remote_host}
events 10
window 1m
}
}
import waf
reverse_proxy app:8080
}
}
coraza/before-crs/10-exclusions.conf:
SecRule REQUEST_URI "@beginsWith /api/upload" \
"id:1000,phase:1,pass,nolog,ctl:ruleRemoveById=920420"
coraza/after-crs/10-custom.conf:
SecRuleRemoveById 942100
SecRule REQUEST_HEADERS:User-Agent "@contains sqlmap" \
"id:2000,phase:1,deny,status:403,log,msg:'Scanner engellendi'"
example.com {
tls /certs/fullchain.pem /certs/privkey.pem
import waf
reverse_proxy app:8080
}
# global.d/dev.caddy — Let's Encrypt'e gitmez, tüm adlar yerel CA'dan
local_certs
skip_install_trust
Tarayıcının güvenmesi için kök sertifikayı alıp sisteminize kurun:
docker compose cp caddy:/data/caddy/pki/authorities/local/root.crt ./caddy-local-root.crt
WAF audit log'u JSON olarak stdout'a yazılır (docker logs). Yalnızca kural eşleşen / engellenen istekler kaydedilir.
En sık tetiklenen kurallar:
docker logs caddy 2>&1 | grep -oE '\[id \\"[0-9]+' | grep -oE '[0-9]+' | sort | uniq -c | sort -rn
Engellenen istekler:
docker logs caddy 2>&1 | grep 'Access denied'
Coraza'nın key not found in collection uyarıları zararsızdır. Gizlemek için:
# global.d/log.caddy
log default {
exclude http.handlers.waf
}
docker exec caddy caddy validate --config /etc/caddy/Caddyfile
docker exec caddy caddy reload --config /etc/caddy/Caddyfile
validate hata verirse reload yapılmaz; Caddy eski yapılandırmayla çalışmaya devam eder.
CORAZA_RULE_ENGINE: "DetectionOnly" ile başlayın, normal trafiği bir süre izleyin."On" yapın. Eşiği yükseltmek yerine istisna yazmayı tercih edin.read_only, cap_drop: ALL + cap_add: NET_BIND_SERVICE ve no-new-privileges ile çalıştırılması önerilir.SecAuditLogParts ABHZ kullanın (parolalar ve kişisel veriler log'a düşmez).Apache-2.0. İçerdiği bileşenler kendi lisanslarına tabidir (Caddy, Coraza, coraza-caddy: Apache-2.0; OWASP CRS: Apache-2.0).
Content type
Image
Digest
sha256:8941c05ea…
Size
27.3 MB
Last updated
1 day ago
docker pull msecapps/caddy-coraza-waf