Traefik Warden: Configuration Reference
This reference covers all configuration options available in Traefik Warden.
Core Options
| Key | Type | Default | Description |
|---|---|---|---|
configFile | string | "" | Path to a routewarden.json file loaded as the base config. Inline fields always take precedence over the file. |
enabled | bool | true | Enables or disables the middleware. When false, all traffic passes through. |
debug | bool | false | Enables verbose diagnostic logging for request candidate normalization, method matching, and allow/block evaluation details. |
securityLog | bool | true | Emits single-line structured JSON security audit events on stdout for CrowdSec, SIEMs, or fail2ban on blocked requests. |
enableDefaultPatterns | bool | true | Enables built-in protection for .env*, .git, .aws, .sql, backups, and logs. |
enableDefaultAllowPatterns | bool | true | Enables built-in allowlist exemptions (/robots.txt, /sitemap.xml, /ads.txt, /security.txt, /.well-known/*). Set to false to disable. |
blockPatterns | []string | [] | List of custom regular expressions to block (matches against normalized path). |
allowPatterns | []string | [] | Additional custom regex patterns to explicitly allow even if matching blocked rules. |
allowedIps | []string | [] | Whitelisted IPv4/IPv6 addresses or CIDR subnets (e.g., 10.0.0.0/8, 127.0.0.1). |
allowedASNs | []string | [] | List of Autonomous System Numbers ("64500" or "AS64500") whose client IPs bypass inspection. Requires asnDB. |
blockedASNs | []string | [] | List of hostile or crawler Autonomous System Numbers whose client IPs are blocked. Requires asnDB. |
asnDB | string | "" | Absolute filesystem path to local JSON ASN-to-CIDR routing snapshot file. |
botDefenseLevel | string | "" | Preset bot defense level ("off", "light", "standard", "strict", "aggressive"). Activates pre-tuned combinations of AI bot defense, browser impersonation checks, script client blocking, and FCrDNS. |
blockAIBots | bool | false | Enables automatic blocking of known AI scrapers, LLM training bots, and crawlers. |
aiBotProfile | string | "" | AI bot profile filter: train_only (default), search_only, agents_only, all, aggressive, or custom. |
blockUserAgents | []string | [] | Custom regular expression patterns matching client User-Agents to block. |
allowUserAgents | []string | [] | Custom regular expression patterns matching client User-Agents to permit. |
detectBrowserImpersonation | bool | false | Cross-validates claimed browser User-Agents against Client Hints (Sec-CH-UA-Platform, Sec-CH-UA-Mobile, Sec-CH-UA brand integrity with GREASE verification), Chromium Fetch Metadata (Sec-Fetch-*), companion headers (Accept-Language, Accept-Encoding), and header ordering anomalies. |
blockScriptClients | bool | false | Blocks automated HTTP client library signatures (requests, Guzzle, reqwest, axios, curl) and headless automation framework headers (X-Playwright, X-Puppeteer, X-Cypress, Sec-WebDriver). |
blockCloudHosts | bool | false | Identifies and blocks requests originating from major cloud hosting and datacenter ASNs (AWS, GCP, Azure, Hetzner, etc.), dropping datacenter scrapers and browser impersonators while exempting verified search crawlers and route allow patterns. |
verifySearchEngineBots | bool | false | Verifies genuine search engine crawlers (Google, Bing, Apple, Yandex, Baidu, DuckDuckGo, Yahoo, Naver, Sogou, Mojeek) via Forward-Confirmed Reverse DNS (FCrDNS), dropping spoofed impersonators. |
honeypotTrapPaths | []string | [] | Hidden decoy URL paths. Any client requesting these paths triggers an instant IP ban in an in-memory sliding-window table. |
enableRobotsTxtHoneypot | bool | false | Dynamically injects daily rotating Disallow: /rw_trap<token>/ entries into /robots.txt and bans scrapers that crawl them. Synthesizes 200 OK when upstream 404s. |
robotsTxtHoneypotSecret | string | "" | Secret seed used to derive deterministic HMAC-SHA256 daily rotating tokens for robots.txt honeypot traps. |
trapBanDuration | string | "24h" | Sliding-window ban duration for trapped client IPs (e.g., 24h, 1h, 30m). |
trustedProxies | []string | [] | Upstream proxies/load-balancers trusted for X-Forwarded-For / X-Real-IP. Untrusted connections use socket IP directly. |
methods | []string | ["GET"] | HTTP request verbs to inspect (e.g. ["GET", "POST"]). Supports wildcard "*" or "ALL" to inspect all verbs. Auto-expanded to include POST, PUT, PATCH when checkBody is enabled without explicit methods. |
checkQuery | bool | false | Also inspects the URL raw query string for blocked patterns. |
checkHeaders | []string | [] | Optional list of HTTP request headers to inspect for path smuggling (e.g. ["X-Forwarded-Uri", "X-Rewrite-URL"]). |
checkBody | bool | false | When true, buffers and inspects request bodies against blocked patterns (auto-expands default methods to include POST, PUT, PATCH). |
checkBodyMaxBytes | int64 | 65536 | Maximum bytes to buffer for body inspection (default: 64KB). |
checkBodyPatterns | []string | [] | Specific regex patterns to match against request body (falls back to blockPatterns if empty). |
statusCode | int | 403 | Default HTTP status code when request is blocked (legacy shortcut). |
Config File (configFile)
Instead of inlining every configuration option in traefik.yml or Docker labels, you can point Routewarden at a shared routewarden.json file. This is especially useful for self-hosters managing multiple services or for keeping security policy in version control independently of your Traefik config.
http: middlewares: warden: plugin: routewarden: configFile: /etc/routewarden/routewarden.json # Inline fields override file values — e.g. override just the response mode: response: mode: tarpitThe routewarden.json file uses the standard Routewarden JSON schema (view it with rwarden schema or the CLI Schema):
Merge Semantics
| Priority | Source |
|---|---|
| 1 (wins) | Inline fields in traefik.yml / Docker labels |
| 2 (base) | Fields from configFile |
- Non-zero inline values always override the corresponding file values.
- Empty/omitted slices in the inline config defer to the file (so you don't need to re-specify
blockPatternsjust to change the response mode). - A missing or malformed file causes a hard startup error — Routewarden will not silently fall back to defaults.
TIP
Mount routewarden.json as a Docker volume or Kubernetes ConfigMap and share it across multiple Traefik middleware instances for consistent policy enforcement across services.
ASN Allowlisting (allowedASNs & asnDB)
Traefik Warden supports Autonomous System Number (ASN) based allowlisting using an offline JSON routing snapshot compiled from MaxMind GeoLite2/GeoIP2 ASN CSV data with scripts/build-asn-db.py.
http: middlewares: warden: plugin: routewarden: allowedASNs: - "AS13335" # Cloudflare - "64500" # Corporate Network asnDB: /etc/routewarden/asn.json trustedProxies: - "10.0.0.0/8"When a request originates from an IP prefix mapped to an allowed ASN in asnDB, Routewarden immediately bypasses path and body inspection (identical to allowedIps). Client-supplied ASN headers (e.g. CF-Connecting-ASN) are strictly ignored; only the socket peer or sanitized IPs from trustedProxies are matched.
For routing snapshot build instructions, JSON formatting, and longest-prefix matching details, refer to the ASN Filtering Guide.
Security Audit Logging (securityLog)
Routewarden includes built-in structured security audit logging designed for CrowdSec, SIEM platforms (Elasticsearch, Loki, Splunk, Datadog), and automated intrusion remediation tools.
When securityLog: true (the default), every intercepted probe emits a single-line JSON payload to stdout:
{ "type": "routewarden_block", "timestamp": "2026-09-19T15:30:00Z", "plugin": "routewarden", "client_ip": "198.51.100.42", "method": "GET", "path": "/.env", "request_uri": "/.env", "pattern": "(?i)(^|/)(\\.env.*|.*\\.(txt|log|bak|backup|sql|conf|config|ini|yaml|yml))$", "action": "json", "reason": "path_blocked", "user_agent": "Nuclei/v3.1.0"}| Field | Description |
|---|---|
type | Constant identifier routewarden_block for log parsers and alerting rules. |
timestamp | ISO-8601 UTC timestamp of the interception. |
plugin | Middleware instance name. |
client_ip | Remote client IP extracted from socket RemoteAddr, X-Forwarded-For, or X-Real-IP. |
method | HTTP request verb (GET, POST, etc.). |
path | Normalized candidate path that triggered the match. |
request_uri | Original raw URI requested by the client. |
pattern | Regular expression pattern that triggered the block. |
action | Response mode executed (json, html, fakeSuccess, silentDrop, etc.). |
reason | Block trigger classification (path_blocked, query_blocked, query_param_blocked, header_blocked). |
user_agent | Inbound client User-Agent header string. |
For complete end-to-end integration steps with automated firewall remediation, see the CrowdSec Integration Guide.
Built-in Default Patterns
Default Block Patterns (enableDefaultPatterns: true)
When enableDefaultPatterns: true (default), Routewarden intercepts requests matching these compiled regular expressions:
| Target Category | Compiled Regex | Intercepted Examples |
|---|---|---|
| Environment & Configs | (?i)(^|/)(\.env.\|.\.(txt\|log\|bak\|backup\|sql\|conf\|config\|ini\|yaml\|yml))$ | /.env, /.env.production, /app.config, /dump.sql, /debug.log, /app.ini |
| VCS & Hidden Metadata | (?i)(^|/)\.(git\|svn\|hg\|bzr\|cvs)(/.*\|$) | /.git/config, /.git/HEAD, /.svn/entries |
| Cloud & Shell Credentials | (?i)(^|/)\.(aws\|ssh\|kube\|docker)(/.*\|$) | /.aws/credentials, /.ssh/id_rsa, /.kube/config |
| Archives & DB Dumps | (?i).*\.(tar\|tar\.gz\|tgz\|zip\|rar\|7z\|gz\|bz2\|iso\|dump\|sqlite\|sqlite3\|db)$ | /backup.tar.gz, /site.zip, /users.dump, /data.sqlite3 |
| Sensitive Admin & Metrics | (?i)(^|/)(phpinfo\.php\|info\.php\|server-status\|server-info\|actuator(/.*)?\|metrics\|heapdump\|trace\|env)$ | /phpinfo.php, /server-status, /actuator/health, /metrics |
| Package Managers & Locks | (?i)(^|/)(composer\.(json\|lock)\|package-lock\.json\|yarn\.lock\|pnpm-lock\.yaml\|Pipfile\|Pipfile\.lock\|requirements\.txt)$ | /package-lock.json, /yarn.lock, /composer.lock, /requirements.txt |
| TLS Keys & Keystores | (?i).*\.(pem\|key\|crt\|pfx\|p12\|jks\|kdb)$ | /server.key, /cert.pem, /keystore.p12 |
| Container Manifests | (?i)(^|/)(dockerfile.\|docker-compose.\.ya?ml)$ | /Dockerfile, /docker-compose.yml, /docker-compose.prod.yaml |
| OS Metadata Structure | (?i)(^|/)\.ds_store$ | /.DS_Store |
| CMS & Framework Configs | (?i)(^|/)(wp-config\.php.\|configuration\.php.\|settings\.py\|local_settings\.py)$ | /wp-config.php, /configuration.php, /settings.py |
Default Allow Patterns (enableDefaultAllowPatterns: true)
When enableDefaultAllowPatterns: true (default), Routewarden immediately permits standard public and ACME paths before testing block patterns:
| Target Resource | Compiled Regex |
|---|---|
| Crawler Indexing Directives | (?i)^/robots\.txt$ |
| Search Engine XML Sitemaps | (?i)^/sitemap.*\.xml$ |
| Digital Ad Transparency | (?i)^/ads\.txt$ |
| Security Disclosure Policies | (?i)^/security\.txt$ |
| ACME & Web Standards | (?i)^/\.well-known(/.*)?$ |
Response Configuration (response)
📖 Deep Dive: For an in-depth breakdown of all 15 response behaviors, limitations, attacker impacts, and security cautions, visit the Response Modes Reference.
| Key | Type | Default | Description |
|---|---|---|---|
mode | string | "text" | Response mode: json, html, text, xml, redirect, captcha, silentDrop, gzipBomb (bomb), tarpit, fakeSuccess (decoy), rateLimitChallenge (ratelimit), proxy (mirror), infiniteStream (garbagestream), aiPoison, markovTarpit, or powChallenge (pow, proofOfWork, hashcash). |
statusCode | int | 403 | HTTP status code returned to client (use 200 for honeypots / deception, 429 for rate limit challenge or powChallenge). |
body | string | "" | Response body for json, html, xml, or text mode. |
headers | map[string]string | {} | Custom HTTP response headers injected into blocked responses. |
redirectUrl | string | "" | Target URL when mode: redirect. |
proxyUrl | string | "" | Target backend honeypot URL when mode: proxy (transparent reverse-proxy). |
captcha | object | {} | Captcha challenge options when mode: captcha. |
gzipBombMB | float | 10 | Uncompressed stream size in Megabytes when mode: gzipBomb (expands ~1000x on client memory; supports fractional values e.g. 0.5). |
retryAfterSeconds | int | 300 | Value for Retry-After header when mode: rateLimitChallenge. |
tarpitDelayMs | int | 1000 | Milliseconds between trickle bytes when mode: tarpit (stalls scanner connections). |
tarpitMaxDurationSeconds | int | 60 | Maximum seconds before terminating stalled connection in mode: tarpit. |
streamSizeMB | int | 50 | Total garbage data size in Megabytes when mode: infiniteStream. |
powDifficulty | int | 16 | Required leading zero bits in SHA-256 output when mode: powChallenge (recommended: 8–24). |
powSecret | string | "" | Secret seed used to compute HMAC-SHA256 signatures for stateless challenge verification when mode: powChallenge. |
powTimeoutSeconds | int | 300 | Expiration and validity window in seconds for proof-of-work challenges and solution tokens. |
Captcha Options (response.captcha)
| Key | Type | Default | Description |
|---|---|---|---|
provider | string | "turnstile" | Captcha provider: turnstile, hcaptcha, or recaptcha. |
siteKey / site_key | string | "" | Public site key for the captcha widget (accepts camelCase siteKey or snake_case site_key). |
title | string | "Verification" | Heading displayed on the verification challenge page. |
template | string | "" | Optional custom HTML template string override. |
HTTP Request Verbs Inspection (methods)
By default, Routewarden inspects incoming GET requests (methods: ["GET"]), as automated scanners and vulnerability reconnaissance probes primarily use GET to check for leaked files (.env, .git, backups, configs).
You can configure methods to inspect additional HTTP request verbs (e.g. POST, PUT, DELETE, PATCH, HEAD) or tailor inspection to specific workloads. Any incoming request whose HTTP method is not included in methods will immediately bypass inspection and pass downstream to upstream containers.
Wildcard Methods (* and ALL)
To inspect all incoming HTTP request methods without enumerating each verb individually, supply "*" or "ALL" (case-insensitive):
methods: - "*"Automatic Method Expansion for Request Body Inspection
When body inspection is enabled (checkBody: true or custom checkBodyPatterns configured) and methods is left at the default ["GET"], Routewarden automatically expands methods to:
methods: - "GET" - "POST" - "PUT" - "PATCH"This ensures that incoming payload-bearing mutation requests (POST, PUT, PATCH) are inspected automatically without requiring boilerplate configuration. If you explicitly specify methods, your custom list is preserved as configured.
Configuration Examples
http: middlewares: routewarden: plugin: routewarden: enabled: true enableDefaultPatterns: true # Inspect GET and POST requests (default: ["GET"]) methods: - "GET" - "POST"