<commit_before># node-http-proxy - v0.1.5

<img src = "http://i.imgur.com/dSSUX.png"/>

## Battle-hardened node.js http proxy

### Features

- reverse-proxies incoming http.Server requests
- can be used as a CommonJS module in node.js
- uses event buffering to support application latency in proxied requests
- minimal request overhead and latency
- fully-tested
- battled-hardened through production usage @ nodejitsu.com
- written entirely in javascript
- easy to use api

### When to use node-http-proxy

Let's suppose you were running multiple http application servers, but you only wanted to expose one machine to the internet. You could setup node-http-proxy on that one machine and then reverse-proxy the incoming http requests to locally running services which were not exposed to the outside network. 


### Installing npm (node package manager)
<pre>
  curl http://npmjs.org/install.sh | sh
</pre>

### Installing node-http-proxy
<pre>
  npm install http-proxy
</pre>

### How to setup a basic proxy server
<pre>
  var http = require('http'),
      httpProxy = require('http-proxy');

  httpProxy.createServer(9000, 'localhost').listen(8000);

  http.createServer(function (req, res){
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.write('request successfully proxied!' + '\n' + JSON.stringify(req.headers, true, 2));
    res.end();
  }).listen(9000);
</pre>

see the [demo](http://github.com/nodejitsu/node-http-proxy/blob/master/demo.js) for further examples.

### How to setup a proxy server with custom server logic
<pre>
  var http = require('http'),
      httpProxy = require('http-proxy');

  // create a proxy server with custom application logic
  httpProxy.createServer(function (req, res, proxyRequest) {
    // Put your custom server logic here
    proxyRequest(9000, 'localhost');
  }).listen(8000);

  http.createServer(function (req, res){
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.write('request successfully proxied: ' + req.url +'\n' + JSON.stringify(req.headers, true, 2));
    res.end();
  }).listen(9000);
  
</pre>

### How to proxy requests with latent operations (IO, etc.)

node-http-proxy supports event buffering, that means if an event (like 'data', or 'end') is raised by the incoming request before you have a chance to perform your custom server logic, those events will be captured and re-raised when you later proxy the request. Here's a simple example:

<pre>
  httpProxy.createServer(function (req, res, proxyRequest) {
    setTimeout(function () {
      proxyRequest(port, server);
    }, latency);
  }).listen(8081);
</pre>

### Why doesn't node-http-proxy have more advanced features like x, y, or z?

If you have a suggestion for a feature currently not supported, feel free to open a [support issue](http://github.com/nodejitsu/node-http-proxy/issues). node-http-proxy is designed to just proxy http requests from one server to another, but we will be soon releasing many other complimentary projects that can be used in conjunction with node-http-proxy.

<br/><br/><br/><br/><br/>

### License

(The MIT License)

Copyright (c) 2010 <NAME>, <NAME> & <NAME><commit_msg>[doc] Updated README.md<commit_after># node-http-proxy - v0.2.0

<img src = "http://i.imgur.com/dSSUX.png"/>

## Battle-hardened node.js http proxy

### Features

- reverse-proxies incoming http.Server requests
- can be used as a CommonJS module in node.js
- uses event buffering to support application latency in proxied requests
- minimal request overhead and latency
- fully-tested
- battled-hardened through production usage @ nodejitsu.com
- written entirely in javascript
- easy to use api

### When to use node-http-proxy

Let's suppose you were running multiple http application servers, but you only wanted to expose one machine to the internet. You could setup node-http-proxy on that one machine and then reverse-proxy the incoming http requests to locally running services which were not exposed to the outside network. 


### Installing npm (node package manager)
<pre>
  curl http://npmjs.org/install.sh | sh
</pre>

### Installing node-http-proxy
<pre>
  npm install http-proxy
</pre>

### How to setup a basic proxy server
<pre>
  var http = require('http'),
      httpProxy = require('http-proxy');

  httpProxy.createServer(9000, 'localhost').listen(8000);

  http.createServer(function (req, res){
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.write('request successfully proxied!' + '\n' + JSON.stringify(req.headers, true, 2));
    res.end();
  }).listen(9000);
</pre>

see the [demo](http://github.com/nodejitsu/node-http-proxy/blob/master/demo.js) for further examples.

### How to setup a proxy server with custom server logic
<pre>
  var http = require('http'),
      httpProxy = require('http-proxy');

  // create a proxy server with custom application logic
  httpProxy.createServer(function (req, res, proxyRequest) {
    // Put your custom server logic here
    proxyRequest(9000, 'localhost');
  }).listen(8000);

  http.createServer(function (req, res){
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.write('request successfully proxied: ' + req.url +'\n' + JSON.stringify(req.headers, true, 2));
    res.end();
  }).listen(9000);
  
</pre>

### How to proxy requests with latent operations (IO, etc.)

node-http-proxy supports event buffering, that means if an event (like 'data', or 'end') is raised by the incoming request before you have a chance to perform your custom server logic, those events will be captured and re-raised when you later proxy the request. Here's a simple example:

<pre>
  httpProxy.createServer(function (req, res, proxyRequest) {
    setTimeout(function () {
      proxyRequest(port, server);
    }, latency);
  }).listen(8081);
</pre>

### Why doesn't node-http-proxy have more advanced features like x, y, or z?

If you have a suggestion for a feature currently not supported, feel free to open a [support issue](http://github.com/nodejitsu/node-http-proxy/issues). node-http-proxy is designed to just proxy http requests from one server to another, but we will be soon releasing many other complimentary projects that can be used in conjunction with node-http-proxy.

<br/>
### License

(The MIT License)

Copyright (c) 2010 <NAME>, <NAME> & <NAME>
{'fraction_non_alphanumeric': 0.12101506740681998, 'fraction_numerical': 0.013639968279143537, 'mean_word_length': 4.065060240963855, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5335826', 'n_tokens_mistral': 1902, 'n_tokens_neox': 1792, 'n_words': 703}