Smockron! Distributed Rate Limiting via Nginx Plugin or Node Middleware (Shut people down when they've made too many HTTP requests)

Fail-safe In the case of server or network outages, Smockron makes sure your application stays accessible. Distributed design doesn't add a single point of failure. Lightweight Smockron uses minimal resources, and causes virtually no slowdown for users who aren't being throttled. Flexible Smockron works no matter what language your application is written in, or what technology you use for load-balancing.

Getting the code Install from NPM: $ npm install smockron Or check it out from GitHub: $ git clone https://github.com/arodland/smockron $ git submodule update --init $ npm install

Master The master aggregates request counts and notifies app servers when thresholds are met. Configure rate limiting criteria and thresholds: $ vi config/default.yaml Start up the master: $ smockron_master # or: node bin/master.js Start up the master:

Express middleware App middleware sends events to the master and listens for throttle notifiactions. Use either this middleware, or the Nginx module below. Configure your application: var Smockron = require('smockron'); var gk = new Smockron.Gatekeeper({ server: "smockron.example.com", domain: "myapp", identifierCB: Smockron.Gatekeeper.REMOTE_ADDR }); app.use(gk.middleware()); Or run the example app: $ node bin/gatekeeper_test.js Or run the example app:

Nginx module If you'd rather limit at the nginx level, use the nginx module instead of the Node middleware. The nginx module sends events to the master and listens for throttle notifiactions. Download and unpack nginx: $ cd smockron/gatekeeper/nginx-module $ ./configure-nginx /path/to/nginx $ ./build-nginx /path/to/nginx Add configuration in nginx.conf: $ smockron on; $ smockron_master tcp://smockron.example.com:10004; $ smockron_domain myapp; Run the example config: $ ./run-nginx /path/to/nginx Add configuration in nginx.conf:Run the example config: