Distributed Rate Limiting via Nginx Plugin or Node Middleware

(Shut people down when they've made too many HTTP requests)


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.


Smockron uses minimal resources, and causes virtually no slowdown for users who aren't being throttled.


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
$ git submodule update --init
$ npm install


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

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: "",
  domain: "myapp",
  identifierCB: Smockron.Gatekeeper.REMOTE_ADDR
Or run the example app:
$ node bin/gatekeeper_test.js

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_domain myapp;
Run the example config:
$ ./run-nginx /path/to/nginx

About Smockron

How does it work?

Application servers use ZeroMQ to send information about incoming requests to a Smockron master server. When the master detects that a client is accessing a resource too frequently, it sends a message to servers with that resource instructing them to deny that client for a period of time.

For more information about the design of Smockron, see the Smockron design documentation.

What do I need?

The Smockron master is written in Node and uses Redis as a data store. The Smockron gatekeeper exists in two versions: as a Node Express middleware, and as an Nginx plugin.

Is it ready to use?

Smockron is beta software under active development. It's not ready for production use quite yet. All of the components have a basic set of features and are reasonably stable, and you're encouraged to try it out and share your experiences.