Environment Variables
Coraza Proxy is configured entirely through environment variables. Below is the complete reference based on the source code.Core Configuration
Port number for the proxy server to listen on.
Backend routing configuration mapping hostnames to backend servers.Format (v2 - recommended):Format (v1 - legacy):
WAF Rule Configuration
Colon-separated list of rule files for website protection (Paranoia Level 1).Default:Example (selective rules):
Colon-separated list of rule files for API protection (Paranoia Level 2).Default:Example (API-focused rules):
Host Classification
Comma-separated list of hostnames to treat as APIs (uses
CORAZA_RULES_PATH_APIS).Comma-separated list of hostnames to treat as websites (uses
CORAZA_RULES_PATH_SITES).If a hostname doesn’t match either list, the request will be rejected with a 500 error.
Rate Limiting
Maximum number of requests per second per IP address.Source:
main.go:413Maximum burst size for rate limiting (allows temporary spikes).Source:
main.go:414Rate limiting uses a token bucket algorithm.
PROXY_RATE_LIMIT sets the refill rate, while PROXY_RATE_BURST sets bucket capacity.Bot Protection
Enable/disable bot blocking based on User-Agent strings.Source:
main.go:375Comma-separated list of User-Agent substrings to block when Source:
PROXY_BLOCK_BOTS is enabled.main.go:449GeoIP Blocking
Enable/disable geographic blocking based on IP address.Requires GeoLite2-Country.mmdb database at
/app/GeoLite2-Country.mmdb.Source: main.go:370-373Comma-separated list of ISO country codes to allow (whitelist mode).If set, only traffic from these countries is allowed.
Comma-separated list of ISO country codes to block (blacklist mode).Blocked countries are denied regardless of whitelist.
IP Reputation (Placeholder)
Enable/disable IP reputation verification.
Volume Mounts
Log Directory
/tmp/log/coraza/audit.log and debug logs to /tmp/log/coraza/debug.log.
Permissions:
Custom Rule Profiles
GeoIP Database
GEO_BLOCK_ENABLED=true.
Networking
Port Mapping
PORT environment variable (default: 8081).
Docker Networks
For multi-container deployments:IP Address Detection
The proxy extracts client IPs from headers in this order:CF-Connecting-IP(Cloudflare)X-Forwarded-For(first IP)RemoteAddr(direct connection)
main.go:250-262
Health Checks
Implement health checks to monitor proxy availability:Docker CLI
Docker Compose
Kubernetes
The proxy doesn’t have a dedicated health endpoint. Health checks connect to backends, so ensure at least one backend is healthy.
Complete Example
.env File
Create a.env file based on .env.example:
Docker Run Command
Troubleshooting
Check Logs
Common Issues
WAF not configured for this host
WAF not configured for this host
Cause: Hostname not listed in Source:
PROXY_APIS_HOSTS or PROXY_WEB_HOSTS.Solution: Add the hostname to the appropriate environment variable:main.go:472-476Bad Gateway: backend not configured
Bad Gateway: backend not configured
Cause: No backend defined for the hostname in Source:
BACKENDS.Solution: Ensure BACKENDS JSON includes the hostname or a “default” entry.main.go:547-550Permission denied on log files
Permission denied on log files
Cause: Log directory not writable by
coraza user (UID 1000).Solution: Fix permissions on host:Too Many Requests (429)
Too Many Requests (429)
Cause: Rate limit exceeded for IP address.Solution: Increase rate limits:Or check if the correct client IP is being detected (reverse proxy headers).Source:
main.go:441-445Next Steps
Docker Deployment
Standalone Docker deployment guide
Docker Compose
Multi-container orchestration
