One place to block or allow IPs on all your n8n webhooks (Firewall Manager + Scope)

Hi everyone!

Ever had one of these?

  • Someone found your webhook URL and is hammering it, and every call burns your AI credits or hits your database.
  • A webhook should only accept calls from one partner (Stripe, GitHub, a client’s server), but anyone can call it.
  • Something went wrong and you need to stop all your webhooks now, and you have to open workflow by workflow.
  • You have 30 webhooks and want to block one IP. That’s 30 IP lists to edit by hand in the Webhook node.

I built @abraao_o_h/n8n-nodes-firewall for this.

How it works

  1. Create a workflow with a Firewall Manager. That’s your single list: the IPs to block or allow, and the switches. It doesn’t need to be active: saving is enough.
  2. Put a Firewall Scope right after each Webhook. Connect Allowed to your flow, and Blocked to a Respond to Webhook (403).
  3. Add an IP to the Manager and save. Within 10 seconds, every Scope blocks it. You never open the other workflows.

You need both: the Manager holds the rules, the Scopes apply them. A Scope with no Manager on its channel lets everything through (or blocks everything, if you set Without a Manager to Block), and a Manager with no Scopes protects nothing.

Webhook → Firewall Scope ─ Allowed → your flow
                         └ Blocked → Respond to Webhook (403 / 429)

Channels: a Manager and its Scopes talk through a channel. Each Manager has one channel, and each Scope picks which channel to follow from a dropdown. You can have as many channels as you want, one for each purpose. For example:

Channel Manager rules Webhooks
payments Allow only Stripe’s IPs Your Stripe webhooks
partners Allow only your clients’ servers Webhooks you give to clients
public Block Tor, rate limit 30/min Forms and public endpoints

Changing the public Manager never touches payments. The same goes for the emergency switch: if your public forms are under attack, set the public Manager to Stop All Scopes and save. Only the public webhooks stop, and payments and partners keep running.

Features

1. Three list modes

  • Block the IPs below: everyone passes except them.
  • Allow only the IPs below: for partner-only webhooks.
  • Allow and Block: each IP gets an action, and Block always wins. Example: allow 10.0.0.0/8 but block 10.0.0.5.

Each IP can be IPv4 or IPv6, alone or a CIDR range (203.0.113.0/24), with a reason and an optional expiration date (“block this IP for 24 hours”).

2. Emergency switches

Channel State What happens
Active Every Scope checks the IP
Stop All Scopes Every webhook of the channel blocks everything
Let Everything Through No check, for maintenance

And Scope Rules override that per webhook. Example: stop everything except the payment webhook, or stop only the one under attack. The Scope list comes from your saved workflows (“Orders → Firewall Scope”), so you pick from a dropdown.

3. Ready-made lists, always up to date

List Source Example use
Country (BR, PT…) Internet registries (LACNIC, RIPE, ARIN…) Allow only Brazil
Tor exit nodes The Tor Project Block Tor
Stripe webhooks stripe.com Your Stripe webhook accepts only Stripe
GitHub webhooks api.github.com/meta Same for GitHub
Cloudflare IPs IP Ranges | Cloudflare

They’re downloaded and refreshed automatically (countries daily, Tor hourly). Note that countries are by IP registration, not exact location: a VPN or a foreign cloud server gets around it.

4. Import from Cloudflare

Already blocking IPs in Cloudflare? Pick your IP Lists or IP Access Rules (zone or account) and the Manager uses them: Block and Challenge become Block, Allow becomes Allow, country rules become country lists. Useful to reuse the rules of another site, or to use a Cloudflare list as an allowlist.

5. Rate limit

Example: 60 requests per minute per IP, with a sliding window.

  • Count per webhook, or across all webhooks of the channel
  • Give one webhook its own limit, or none
  • Optionally skip IPs you explicitly allowed
  • Count in memory (one n8n), or in Redis (queue mode, shared by all processes, using n8n’s Redis credential). If Redis goes down, it falls back to memory.

Over the limit, the request goes to Blocked with retryAfter, so you can answer 429 with a Retry-After header.

6. You know why it was blocked

Blocked items keep the original data and get a firewall field:

{ "allowed": false, "reason": "ip_blocked", "ip": "203.0.113.7", "channel": "production", "rule": "203.0.113.7", "note": "spam" }

Reasons: ip_blocked, ip_not_allowed, rate_limited, channel_stopped, scope_stopped, no_ip. Since Blocked is a normal output, you can log it, alert on Slack, or answer differently per reason.

7. Execute step shows everything

Run the Manager and it shows what the Scopes get: the IPs in force, expired and invalid entries, each list with how many ranges it loaded, every Scope of the channel with its state, and warnings (two Managers on the same channel, a country code with no IPs…).

Setup notes

  • Both nodes use the n8n API credential that comes with n8n (read-only scopes are enough).
  • Choose in the Scope where your proxy puts the client IP: Cloudflare (CF-Connecting-IP), X-Forwarded-For, X-Real-IP, or an expression. Any header your proxy doesn’t set can be faked.
  • If the n8n API fails, Scopes keep the last list they read. They never fail open silently.

What it is not

It runs after n8n receives the request. It protects your flows and what they call (APIs, AI, databases), not n8n itself from DDoS. Keep Cloudflare or your proxy in front for that. This is the layer for your rules: who can call which flow, how often, and what happens when they’re blocked.

Try it

Copy this workflow into n8n (or click the copy button on the preview). It has one example per mode: Block, Allow, Mixed and Rate Limit, each with its own channel and a pinned Webhook. Select your n8n API credential, save, and run Execute step on each Scope to see which IPs pass and why, without sending any request.

Install: Settings → Community Nodes → @abraao_o_h/n8n-nodes-firewall
Docs: https://www.npmjs.com/package/@abraao_o_h/n8n-nodes-firewall

Feedback is very welcome. Next on my list: replay protection.

1 Like