An Express.js middleware for IP-based access control, supporting whitelist/blacklist modes, IPv4, IPv6, CIDR, and IPv4-mapped IPv6 addresses. Current stable version is 1.1.3, released June 2018, with no recent updates. Key features include force connection address, custom deny actions (redirect or message), custom logging, and Node.js/Express 4 compatibility. Differentiators: lightweight, zero dependencies besides ipaddr.js (bundled), simple API for common IP filtering patterns.
npm install express-ip-access-controlVerified import paths — ran on the pinned version, not inferred.
Shows basic setup: require the package, configure options for deny mode, block specific IPs and CIDR ranges, apply middleware to Express app.
Use exact property names: denys and allows (with 'y' and double 'l').
Consider alternatives like express-ipfilter or write custom middleware using ipaddr.js directly.
Set statusCode to 301 or 302 along with redirectTo for redirect behavior.
Be explicit in your lists: use pure IPv4 or pure IPv6 addresses; understand that conversion happens automatically.
In 'allow' mode, only IPs in 'allows' (minus any in 'denys') are allowed. Use the mode that matches your mental model: 'deny' for blacklist, 'allow' for whitelist.
Use const AccessControl = require('express-ip-access-control');Run npm install express
Ensure options object is provided: AccessControl({ denys: [...], ... })Ensure all IP strings are valid IPv4, IPv6, or CIDR notation (e.g., '192.168.1.1', '::1', '10.0.0.0/24').