Giter Club home page Giter Club logo

rl-proxy's Introduction

rl-proxy

rate limiting http proxy server for JSON-based services.

Features

  • HMAC signed keys require no key database for validation.
  • Organization ID, Application ID, expiration date, and credit limit can be embedded in keys.
  • Translate JSONP requests to non-JSONP requests on the backend.
  • Strip cache busting headers and query params.
  • Count credits based on IP address or key.
  • Provide /credit.json for credits remaining, limit and reset times.

Overview


rl-keygen is used to generate keys

$ ./rl-keygen --secret=12345 --org_id=42 --app_id=1 --expire=1d --credits=240000
XQW2MHYHE3NTC2NDFIAAAAAAAAAQBXBHCIAIBKID
{org_id:42,app_id:1,expires:2012/2/18,flags:0,credits:240000}

$ ./rl-keygen --secret=12345 --org_id=42 --app_id=2 --expire=2000/1/1 --credits=240000
MVA26DOSEN4FD77CFIAAAAAAAABABUAXAEAIBKID
{org_id:42,app_id:2,expires:2000/1/1,flags:0,credits:240000}

rl-proxy sits in front of your caching reverse proxys and application servers

$ ./rl-proxy --backend=localhost:3000 --secret=12345 --reset-duration 24:00:00 --vhost api.example.com --port 8800

$ curl -i http://localhost:8800/credit.json
HTTP/1.1 200 OK
Content-Length: 202
Content-Type: application/json
Date: Sat, 18 Feb 2012 01:20:58 GMT

{"response":{"limit":3600,"reset":1329552000,"refresh_in_secs":23942,"remaining":3600},
"request":{"parameters":{},"response_type":"json","resource":"credit",
"url":"http://api.example.com/credit.json"}}

$ curl -i http://localhost:8800/credit.json?apikey=XQW2MHYHE3NTC2NDFIAAAAAAAAAQBXBHCIAIBKID
HTTP/1.1 200 OK
Content-Length: 254
Content-Type: application/json
Date: Sat, 18 Feb 2012 01:21:23 GMT

{"response":{"limit":240000,"reset":1329552000,"refresh_in_secs":23917,"remaining":240000},
"request":{"parameters":{},"response_type":"json","resource":"credit",
"url":"http://api.example.com/credit.json?apikey=XQW2MHYHE3NTC2NDFIAAAAAAAAAQBXBHCIAIBKID"}}

$ curl -i http://localhost:8800/credit.json?apikey=MVA26DOSEN4FD77CFIAAAAAAAABABUAXAEAIBKID
HTTP/1.1 400 Expired Key
Connection: close
Content-Length: 0
Date: Sat, 18 Feb 2012 01:55:31 GMT

credit-server is the central UDP-based in-memory storage for credits

$ ./credit-server --reset-duration 24:00:00

Dependencies


  • cmake >= 2.8
  • g++ >= 4.7
  • libssl-dev >= 0.9.8
  • libboost-dev >= 1.40
  • libboost-date-time-dev >= 1.40
  • libboost-program-options-dev >= 1.40
  • libboost-test-dev >= 1.40
  • ragel >= 6.5

Build


$ git clone https://[email protected]/toffaletti/rl-proxy.git
$ cd rl-proxy
$ git submodule update --init
$ mkdir build; cd build
$ cmake ..
$ make -j4

rl-proxy's People

Contributors

toffaletti avatar

Stargazers

 avatar Angus H. avatar Owen Convey avatar Hady Mahmoud avatar Mohiuddin Khan Inamdar avatar Brad Lhotsky avatar Damian Gryski avatar Iain Ballard avatar Ollie Charles avatar Jon Olsson avatar Ruben Gutierrez avatar Daniel Waardal avatar Pedro Larroy avatar  avatar William Wharton avatar  avatar Logyi, hajnalvédő avatar Michalis™ avatar Michael Rose avatar HaRold avatar Gaurav Verma avatar  avatar Aaron Forsander avatar Jesper Andre Lyngesen Pedersen avatar Jeethu Rao avatar Scott  Koon avatar Martin Clausen avatar Shahzad Bhatti avatar kristopher tate avatar Shane Hanna avatar Sébastien Pierre avatar Bertrand Mansion avatar Blake Watters avatar Rob Cowie avatar Peter Haza avatar Antonio Pardo avatar Max Riveiro avatar Kunal Anand avatar Stoyan Zhekov avatar Lourens Naudé avatar

Watchers

 avatar James Cloos avatar  avatar

Forkers

xorlev ajayk

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.