Repository navigation
Ban at Cloudflare's edge; behind = cloudflare; warn when the log has Cloudflare's addresses - #14
Merged
Merged
Conversation
…Cloudflare's addresses [cloudflare] keeps one account-level IP list (default jevban) and adds one rule per zone, ip.src in $jevban (block): an address caught on one site is blocked on every site of the account. The list is replaced whole after each batch from the active bans (PUT items, polled until completed), so a failed update is put right by the next; expired bans leave it. Errors are logged and retried; jevban keeps running. Local [action] bans still run, for requests straight to the server. HttpJson in Ban.Https makes any HTTP method. behind = cloudflare (implied by [cloudflare]) never judges or bans Cloudflare's addresses. Without it, jevban warns when 30% of the first 2,000 requests come from them: on a real server's day, rules alone would have banned 343 Cloudflare addresses (19 carrying the site's own wp-cron). tests/mock_cloudflare.py implements the documented calls (one pending bulk operation, one list and five rules per zone as on the free plan); tests/cloudflare_e2e.sh runs jevban against it in CI. 219 checks. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NPVFJFY41846T15QqxmGW2
FMXExpress
force-pushed
the
cloudflare
branch
from
November 15, 2026 05:34
e59f3b8 to
76da559
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For sites behind Cloudflare. On one real WordPress server, 82% of a day's 100,760 requests came from 1,430 Cloudflare addresses, because Apache logged the proxy rather than the visitor. Rules alone would have banned 343 Cloudflare addresses: each carries many visitors, none of them the attacker, and 19 carried the site's own
wp-croncalls.[cloudflare]: ban at the edge, for every site in the accountlist = jevban) and adds one rule to each site:ip.src in $jevban, action block. An address caught on one site is blocked on all of them. A new site gets its rule the next time jevban starts, and a restart doesn't duplicate rules.PUT …/items, polled until it completes. A failed update is put right by the next one, entries left over from before a restart are removed, and expired bans leave the list. Cloudflare allows one pending bulk operation per account, which the action thread's single worker guarantees.max_items(10,000, the free plan's total across lists) drops the oldest bans first. The free plan allows one custom list; if it's already in use,list =can name that existing IP list. The errors say so.[action]keeps working alongside it for requests straight to the server's address (18% of that day, half of them probes). A visitor's address in the server's firewall can't hurt traffic that arrives through Cloudflare.behind = cloudflare, and a warningbehind = cloudflareadds Cloudflare's published ranges (ips-v4 and ips-v6, November 2026) toignoreip;[cloudflare]implies it. On the real log: 512 bans → 169, all of them direct connections. Every ban sampled was a real scanner (wordlist walkers, plugin fingerprinters,.envand.githunters).mod_remoteipconfig (CF-Connecting-IP, Cloudflare's ranges) that makes the log carry the visitor's address.Tests
tests/mock_cloudflare.pyimplements the documented calls (the lists, the asynchronous bulk replace and its status, zones, zone entry-point rulesets, rule creation) with the documented envelope and free-plan limits: one list, one pending operation, five rules per zone.tests/cloudflare_e2e.sh, in CI), with three sites, one of which already has a custom rule:[cloudflare]implyingbehind, a missing token refused).[cloudflare]isn't configured.Not yet tested against Cloudflare itself. That needs an API token on the account.
Generated by Claude Code