GitXplorerGitXplorer
t

rl-proxy

public
40 stars
2 forks
0 issues

Commits

List of commits on branch master.
Unverified
7ce1f7008473eddce78547399df86c19644e2cf3

update libten

ttoffaletti committed 12 years ago
Unverified
719609398a8ad492c5fa49fc064a713e0a69469a

v0.1.12

ttoffaletti committed 12 years ago
Unverified
8aa387011969133de0006b458249cafa2a82fcb5

fix traffic mirroring

ttoffaletti committed 12 years ago
Unverified
30b4859fcc0e46e401d3c8d347a7999d3b5c147c

minor

ttoffaletti committed 12 years ago
Unverified
948dae3d8d7a194cc1544a96d1b5407a45008536

v0.1.11

ttoffaletti committed 12 years ago
Unverified
085b3537063aea23d35f504ec06d7717157dfd1b

fix memory leak when credit-server isn't running. exit credit-server if can't listen

ttoffaletti committed 12 years ago

README

The README file for this repository.

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://toffaletti@github.com/toffaletti/rl-proxy.git
$ cd rl-proxy
$ git submodule update --init
$ mkdir build; cd build
$ cmake ..
$ make -j4