racker/node-rproxy

Name: node-rproxy

Owner: racker

Description: A reverse proxy for RESTful services

Created: 2012-04-19 20:22:17.0

Updated: 2016-07-18 18:14:45.0

Pushed: 2013-05-21 00:39:24.0

Homepage:

Size: 4408

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

node-rproxy

A reverse proxy for RESTful services.

Features

Concepts

Middleware

Middleware is a node module which exposes a single method and acts on a request or a response. There are two types of middleware:

Note: Currently response middleware is only limited to modifying the response headers.

Requirements

Configuration

Configuration is stored in a JSON format in a file. Example configuration can be found in example/config.json.

Reverse proxy configuration (“server” attribute)
Admin API configuration (“admin_api” attribute)

Backend a.k.a. proxy target configuration (“target” attribute)

Special headers which are added to every request

A list of special headers which are added to every request by rproxy before proxying it to the backend server.

This ID can be used to track and map requests between rproxy and backend server even when tracing middleware is not used.

Middleware configuration options

Identity provider

This middleware parses a user tenant id from the URL or a header called X-Tenant-Id and puts it on the request object.

Settings
Authentication

This middleware authenticates a user against the Keystone API. It expects authentication token to be provided in the header with the name X-Auth-Token or in the query string with the name x-auth-token.

Unless ?skip-auth-cache query string is provided, token is stored in the cache until it expires.

Settings
Error codes
Rate limiting

This middleware provides flexible rate limiting based on the requested paths.

Settings
Error codes
Usage

This middleware intercepts special usage headers returned by the backend and sends usage events to an Atom Hopper instance.

Settings
Header remover

This middleware removes headers with the specified prefix from the response.

Special header names
Tracing

This middleware integrated wits Zipkin distributed tracing. It supports submitting traces to a remote RESTkin endpoint.

For more information about tracing, please have a look at the Node tracing client called https://github.com/racker/node-tryfer.

Note: This middleware is special, because if enabled, it integrates with other middleware such as authentication and rate limiting.

Settings
Other

This middleware propagates parent trace ID in the request header called x-b3-traceid to the backend server.

This ID can be used by the backend server to attach other child traces to it.

Running lint and tests

By default tests are automatically run on every commit on Travis-ci. You can view the build status at http://travis-ci.org/#!/racker/node-rproxy.

If you want to run them locally you need to have either Redis or Cassandra (or both) installed.

Running lint

npm run-script lint

Running tests with Redis backend

DB_BACKEND=redis REDIS_HOME=<path to the directory containg redis-server binary> npm run-script test

Running tests with Cassandra backend

DB_BACKEND=cassandra CASSANDRA_HOME=<path to the directory containg cassandra binary> CASSANDRA_CONF=<path to cassandra configuration> npm run-script test

Sample configurations for Cassandra 1.1 and 1.2 are kept in tests/conf/cass-1.1 and tests/cass/cass-1.2. You are welcome to use them during development, or you can specify your own configuration. By default, Travis-CI runs all tests against Cassandra 1.1.

TODO


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.