[TR] Resmi nginx:alpine imajı üzerine kurulmuş, ModSecurity v3 ve OWASP Core Rule Set (CRS) v4 içeren, root olmadan çalışan bir Web Application Firewall (WAF) imajı. Nginx güvenlik yamaları yayımlandığında hızla yeniden derlenir.
[EN] A nonroot Web Application Firewall (WAF) image built on the official nginx:alpine image, bundling ModSecurity v3 and the OWASP Core Rule Set (CRS) v4. Rebuilt promptly when Nginx security patches are released.
| Etiket / Tag | Açıklama / Description |
|---|---|
latest | En güncel build / Latest build |
<nginx>-crs<crs> (örn. / e.g. 1.30.7-crs4.30.0) | Sabit sürüm / Pinned version |
Platformlar / Platforms: linux/amd64, linux/arm64
docker pull msecapps/nginx-waf:latest
| Bileşen / Component | Sürüm / Version |
|---|---|
| Nginx (stable) | 1.30.8 |
| ModSecurity (libmodsecurity) | 3.0.17 |
| ModSecurity-nginx connector | 1.0.4 |
| OWASP CRS | 4.31.0 |
nginx kullanıcısı (UID 101) ile çalışır. / Runs as the nginx user (UID 101).-e ile değiştirilir. / Rule engine, paranoia level and anomaly thresholds are set with -e.stream.d/ ile TCP/UDP yönlendirme (örn. PostgreSQL). / TCP/UDP proxying via stream.d/ (e.g. PostgreSQL).| Değişken / Variable | Varsayılan / Default | Açıklama / Description |
|---|---|---|
MODSEC_RULE_ENGINE | On | On, Off, DetectionOnly |
PARANOIA | 1 | CRS paranoia seviyesi / CRS paranoia level (1–4) |
ANOMALY_INBOUND | 5 | Gelen istek engelleme eşiği / Inbound blocking threshold |
ANOMALY_OUTBOUND | 4 | Giden yanıt engelleme eşiği / Outbound blocking threshold |
MODSEC_REQ_BODY_LIMIT | 13107200 | İstek gövdesi limiti (bayt, dosyalar dahil) / Request body limit (bytes, incl. files) |
MODSEC_REQ_BODY_NOFILES_LIMIT | 131072 | Dosya hariç gövde limiti (bayt) / Body limit excluding files (bytes) |
MODSEC_RESP_BODY_ACCESS | On | Yanıt gövdesini incele / Inspect response bodies |
MODSEC_RESP_BODY_LIMIT | 1048576 | Yanıt gövdesi limiti (bayt) / Response body limit (bytes) |
MODSEC_AUDIT_ENGINE | RelevantOnly | On, Off, RelevantOnly |
MODSEC_AUDIT_LOG | /dev/stdout | Audit log hedefi / Audit log target |
MODSEC_AUDIT_LOG_FORMAT | JSON | JSON veya / or Native |
docker run -d -p 8080:8080 msecapps/nginx-waf:latest
curl http://localhost:8080/healthz
[TR] WAF'ın çalıştığını test edin; bu istek 403 dönmelidir:
[EN] Test that the WAF works; this request should return 403:
curl -i "http://localhost:8080/?id=1%27%20OR%20%271%27=%271"
conf.d/app.conf
upstream app_backend {
zone app_backend 64k;
server app:3000 resolve;
}
server {
listen 8080;
server_name example.com;
location / {
proxy_pass http://app_backend;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
docker-compose.yml
services:
waf:
image: msecapps/nginx-waf:latest
ports:
- "80:8080"
- "443:8443"
environment:
MODSEC_RULE_ENGINE: DetectionOnly # ilk kurulumda önce izleyin / observe first
PARANOIA: 1
ANOMALY_INBOUND: 5
volumes:
- ./conf.d:/etc/nginx/conf.d:ro
- ./ssl:/etc/nginx/ssl:ro
- ./modsec/before-crs.conf:/etc/modsecurity.d/before-crs.conf:ro
- ./modsec/after-crs.conf:/etc/modsecurity.d/after-crs.conf:ro
cap_drop: [ALL]
security_opt:
- no-new-privileges:true
restart: always
app:
image: my-app:latest
| Dosya / File | Ne zaman yüklenir / Loaded | Ne için / Use for |
|---|---|---|
/etc/modsecurity.d/before-crs.conf | CRS'ten önce / before CRS | ctl:ruleRemoveById, SecAction, CRS uygulama istisnaları / CRS app exclusions |
/etc/modsecurity.d/after-crs.conf | CRS'ten sonra / after CRS | SecRuleRemoveById, SecRuleUpdateTargetById |
before-crs.conf
# /api/ altında bir SQL injection kuralını kapat
SecRule REQUEST_URI "@beginsWith /api/" \
"id:10000,phase:1,pass,nolog,ctl:ruleRemoveById=942100"
after-crs.conf
SecRuleRemoveById 920420
[TR] Kendi kural ID'lerinizi 10000–99999 aralığında seçin; CRS bu aralığı kullanmaz.
[EN] Use IDs in the 10000–99999 range for your own rules; CRS does not use this range.
stream.d/postgres.conf
upstream pg_backend {
zone pg_backend 64k;
server postgres:5432 resolve;
}
server {
listen 5432;
proxy_pass pg_backend;
}
volumes:
- ./stream.d:/etc/nginx/stream.d:ro
[TR] Resmi nginx imajının şablon desteği çalışır: /etc/nginx/templates/*.conf.template dosyalarındaki ${DEGISKEN} ifadeleri başlangıçta ortam değişkenleriyle doldurulup conf.d/ içine yazılır. Bu özelliği kullanırken conf.d/ klasörünü bağlamayın.
[EN] The official nginx image template support works: ${VAR} expressions in /etc/nginx/templates/*.conf.template are filled from environment variables at startup and written to conf.d/. Do not mount conf.d/ when using this feature.
8080 portunu dinler. Docker 20.10+ konteyner içinde root olmadan 80/443 portlarına da izin verir; Kubernetes'te pod'a net.ipv4.ip_unprivileged_port_start=0 sysctl ayarını verin veya 8080/8443 kullanın. / [EN] The default site listens on 8080. Docker 20.10+ also allows binding 80/443 without root inside the container; in Kubernetes, set the net.ipv4.ip_unprivileged_port_start=0 sysctl on the pod or use 8080/8443./run/nginx/nginx.pid. [TR] Kendi nginx.conf dosyanızı bağlarsanız pid /run/nginx/nginx.pid; ve load_module modules/ngx_http_modsecurity_module.so; satırlarını ekleyin. / [EN] If you mount your own nginx.conf, include pid /run/nginx/nginx.pid; and load_module modules/ngx_http_modsecurity_module.so;.docker run --rm msecapps/nginx-waf:latest nginx -V 2>&1 | head -1
docker run --rm msecapps/nginx-waf:latest nginx -t
[TR] Bu imaj; Nginx (BSD-2-Clause), ModSecurity (Apache-2.0) ve OWASP CRS (Apache-2.0) projelerini değiştirmeden içerir.
[EN] This image bundles Nginx (BSD-2-Clause), ModSecurity (Apache-2.0) and OWASP CRS (Apache-2.0) without modification.
Maintainer: Github.
Content type
Image
Digest
sha256:c14d5fac5…
Size
29.4 MB
Last updated
1 day ago
docker pull msecapps/nginx-waf