Pure Node.js simple rate limiting server to prevent bruteforce attacks
This project is maintained by yonjah
Express middleware for ralphi pure Node.js rate limiting server
Ralphi
is a simple rate limiting server intended to prevent bruteforce attacks on logins and other sensitive assets.
For more info about Ralphi other components see ralphi
$ npm install -s ralphi-client
$ npm install -s express-ralphi
const express = require('express');
const app = express();
const RateLimit = require('express-ralphi');
const client = new require('ralphi-client')();
app.use('/login', RateLimit({bucket: 'login', client}));
app.get('/login', (rec, res) => res.send('Success'));
login
root will be rate limited according to the bucket settings, and rate limiting headers will be sent with the response.
request.info.remoteAddress
is used.onError
the middleware will keep processing the requestFor convince each configuration option has a method that will create a new instance extending the exiting configuration. so it is easy to have specific route configuration -
const express = require('express');
const app = express();
const RateLimit = require('express-ralphi');
const client = new require('ralphi-client')();
const baseRateLimit = RateLimit({bucket: 'login', client, errorLog: e => console.log(e)});
app.use('/login', baseRateLimit);
app.get('/login', (rec, res) => res.send('Success'));
app.use('/recover', baseRateLimit.bucket('recover'));
app.get('/recover', (rec, res) => res.send('Success'));
app.use('/api', baseRateLimit.onError((e, req, res, next) => next()).bucket('api'));
app.get('/api', (rec, res) => res.send('Success'));