Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

http-proxy

Package Overview
Dependencies
Maintainers
4
Versions
85
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http-proxy - npm Package Compare versions

Comparing version 1.12.0 to 1.12.1

4

lib/http-proxy/passes/web-outgoing.js

@@ -85,3 +85,5 @@ var url = require('url'),

Object.keys(proxyRes.headers).forEach(function(key) {
res.setHeader(key, proxyRes.headers[key]);
if(proxyRes.headers[key] != undefined){
res.setHeader(key, proxyRes.headers[key]);
}
});

@@ -88,0 +90,0 @@ },

{
"name": "http-proxy",
"version": "1.12.0",
"version": "1.12.1",
"repository": {

@@ -17,3 +17,3 @@ "type": "git",

"eventemitter3": "1.x.x",
"requires-port": "0.x.x"
"requires-port": "1.x.x"
},

@@ -28,6 +28,7 @@ "devDependencies": {

"mocha-lcov-reporter": "*",
"semver": "^4.3.3",
"semver": "^5.0.3",
"socket.io": "*",
"socket.io-client": "*",
"ws": "~0.5.0"
"sse": "0.0.6",
"ws": "^0.8.0"
},

@@ -34,0 +35,0 @@ "scripts": {

@@ -8,2 +8,9 @@ <p align="center">

<p align="left">
<a href="https://travis-ci.org/nodejitsu/node-http-proxy" target="_blank">
<img src="https://travis-ci.org/nodejitsu/node-http-proxy.png"/></a>&nbsp;&nbsp;
<a href="https://coveralls.io/r/nodejitsu/node-http-proxy" target="_blank">
<img src="https://coveralls.io/repos/nodejitsu/node-http-proxy/badge.png"/></a>
</p>
`node-http-proxy` is an HTTP programmable proxying library that supports

@@ -13,2 +20,24 @@ websockets. It is suitable for implementing components such as

### Table of Contents
* [Installation](#installation)
* [Upgrading from 0.8.x ?](#upgrading-from-08x-)
* [Core Concept](#core-concept)
* [Use Cases](#use-cases)
* [Setup a basic stand-alone proxy server](#setup-a-basic-stand-alone-proxy-server)
* [Setup a stand-alone proxy server with custom server logic](#setup-a-stand-alone-proxy-server-with-custom-server-logic)
* [Setup a stand-alone proxy server with proxy request header re-writing](#setup-a-stand-alone-proxy-server-with-proxy-request-header-re-writing)
* [Modify a response from a proxied server](#modify-a-response-from-a-proxied-server)
* [Setup a stand-alone proxy server with latency](#setup-a-stand-alone-proxy-server-with-latency)
* [Using HTTPS](#using-https)
* [Proxying WebSockets](#proxying-websockets)
* [Options](#options)
* [Listening for proxy events](#listening-for-proxy-events)
* [Shutdown](#shutdown)
* [Miscellaneous](#miscellaneous)
* [Test](#test)
* [ProxyTable API](#proxytable-api)
* [Logo](#logo)
* [Contributing and Issues](#contributing-and-issues)
* [License](#license)
### Installation

@@ -18,13 +47,10 @@

### Build Status
**[Back to top](#table-of-contents)**
<p align="center">
<a href="https://travis-ci.org/nodejitsu/node-http-proxy" target="_blank">
<img src="https://travis-ci.org/nodejitsu/node-http-proxy.png"/></a>&nbsp;&nbsp;
<a href="https://coveralls.io/r/nodejitsu/node-http-proxy" target="_blank">
<img src="https://coveralls.io/repos/nodejitsu/node-http-proxy/badge.png"/></a>
</p>
### Upgrading from 0.8.x ?
### Looking to Upgrade from 0.8.x ? Click [here](UPGRADING.md)
Click [here](UPGRADING.md)
**[Back to top](#table-of-contents)**
### Core Concept

@@ -38,4 +64,5 @@

var proxy = httpProxy.createProxyServer(options);
var proxy = httpProxy.createProxyServer(options); // See (†)
```
†Unless listen(..) is invoked on the object, this does not create a webserver. See below.

@@ -77,3 +104,6 @@ An object will be returned with four values:

**[Back to top](#table-of-contents)**
### Use Cases
#### Setup a basic stand-alone proxy server

@@ -87,3 +117,3 @@

//
httpProxy.createProxyServer({target:'http://localhost:9000'}).listen(8000);
httpProxy.createProxyServer({target:'http://localhost:9000'}).listen(8000); // See (†)

@@ -99,3 +129,6 @@ //

```
†Invoking listen(..) triggers the creation of a web server. Otherwise, just the proxy instance is created.
**[Back to top](#table-of-contents)**
#### Setup a stand-alone proxy server with custom server logic

@@ -128,8 +161,5 @@ This example show how you can proxy a request using your own HTTP server

```
#### Modify a response from a proxied server
Sometimes when you have received a HTML/XML document from the server of origin you would like to modify it before forwarding it on.
[Harmon](https://github.com/No9/harmon) allows you to do this in a streaming style so as to keep the pressure on the proxy to a minimum.
**[Back to top](#table-of-contents)**
#### Setup a stand-alone proxy server with proxy request header re-writing

@@ -172,2 +202,11 @@ This example shows how you can proxy a request using your own HTTP server that

**[Back to top](#table-of-contents)**
#### Modify a response from a proxied server
Sometimes when you have received a HTML/XML document from the server of origin you would like to modify it before forwarding it on.
[Harmon](https://github.com/No9/harmon) allows you to do this in a streaming style so as to keep the pressure on the proxy to a minimum.
**[Back to top](#table-of-contents)**
#### Setup a stand-alone proxy server with latency

@@ -207,58 +246,4 @@

#### Listening for proxy events
**[Back to top](#table-of-contents)**
* `error`: The error event is emitted if the request to the target fail.
* `proxyReq`: This event is emitted before the data is sent. It gives you a chance to alter the proxyReq request object. Applies to "web" connections
* `proxyReqWs`: This event is emitted before the data is sent. It gives you a chance to alter the proxyReq request object. Applies to "websocket" connections
* `proxyRes`: This event is emitted if the request to the target got a response.
* `open`: This event is emitted once the proxy websocket was created and piped into the target websocket.
* `close`: This event is emitted once the proxy websocket was closed.
* (DEPRECATED) `proxySocket`: Deprecated in favor of `open`.
```js
var httpProxy = require('http-proxy');
// Error example
//
// Http Proxy Server with bad target
//
var proxy = httpProxy.createServer({
target:'http://localhost:9005'
});
proxy.listen(8005);
//
// Listen for the `error` event on `proxy`.
proxy.on('error', function (err, req, res) {
res.writeHead(500, {
'Content-Type': 'text/plain'
});
res.end('Something went wrong. And we are reporting a custom error message.');
});
//
// Listen for the `proxyRes` event on `proxy`.
//
proxy.on('proxyRes', function (proxyRes, req, res) {
console.log('RAW Response from the target', JSON.stringify(proxyRes.headers, true, 2));
});
//
// Listen for the `open` event on `proxy`.
//
proxy.on('open', function (proxySocket) {
// listen for messages coming FROM the target here
proxySocket.on('data', hybiParseAndLogMessage);
});
//
// Listen for the `close` event on `proxy`.
//
proxy.on('close', function (req, socket, head) {
// view disconnected websocket connections
console.log('Client disconnected');
});
```
#### Using HTTPS

@@ -301,2 +286,4 @@ You can activate the validation of a secure SSL certificate to the target connection (avoid self signed certs), just set `secure: true` in the options.

**[Back to top](#table-of-contents)**
#### Proxying WebSockets

@@ -342,10 +329,4 @@ You can activate the websocket support for the proxy using `ws:true` in the options.

### Contributing and Issues
**[Back to top](#table-of-contents)**
* Search on Google/Github
* If you can't find anything, open an issue
* If you feel comfortable about fixing the issue, fork the repo
* Commit to your local branch (which must be different from `master`)
* Submit your Pull Request (be sure to include tests and update documentation)
### Options

@@ -381,2 +362,62 @@

**[Back to top](#table-of-contents)**
### Listening for proxy events
* `error`: The error event is emitted if the request to the target fail. **We do not do any error handling of messages passed between client and proxy, and messages passed between proxy and target, so it is recommended that you listen on errors and handle them.**
* `proxyReq`: This event is emitted before the data is sent. It gives you a chance to alter the proxyReq request object. Applies to "web" connections
* `proxyReqWs`: This event is emitted before the data is sent. It gives you a chance to alter the proxyReq request object. Applies to "websocket" connections
* `proxyRes`: This event is emitted if the request to the target got a response.
* `open`: This event is emitted once the proxy websocket was created and piped into the target websocket.
* `close`: This event is emitted once the proxy websocket was closed.
* (DEPRECATED) `proxySocket`: Deprecated in favor of `open`.
```js
var httpProxy = require('http-proxy');
// Error example
//
// Http Proxy Server with bad target
//
var proxy = httpProxy.createServer({
target:'http://localhost:9005'
});
proxy.listen(8005);
//
// Listen for the `error` event on `proxy`.
proxy.on('error', function (err, req, res) {
res.writeHead(500, {
'Content-Type': 'text/plain'
});
res.end('Something went wrong. And we are reporting a custom error message.');
});
//
// Listen for the `proxyRes` event on `proxy`.
//
proxy.on('proxyRes', function (proxyRes, req, res) {
console.log('RAW Response from the target', JSON.stringify(proxyRes.headers, true, 2));
});
//
// Listen for the `open` event on `proxy`.
//
proxy.on('open', function (proxySocket) {
// listen for messages coming FROM the target here
proxySocket.on('data', hybiParseAndLogMessage);
});
//
// Listen for the `close` event on `proxy`.
//
proxy.on('close', function (req, socket, head) {
// view disconnected websocket connections
console.log('Client disconnected');
});
```
**[Back to top](#table-of-contents)**
### Shutdown

@@ -398,4 +439,12 @@

### Test
**[Back to top](#table-of-contents)**
### Miscellaneous
#### ProxyTable API
A proxy table API is available through through this add-on [module](https://github.com/donasaur/http-proxy-rules), which lets you define a set of rules to translate matching routes to target routes that the reverse proxy will talk to.
#### Test
```

@@ -405,6 +454,18 @@ $ npm test

### Logo
#### Logo
Logo created by [Diego Pasquali](http://dribbble.com/diegopq)
**[Back to top](#table-of-contents)**
### Contributing and Issues
* Search on Google/Github
* If you can't find anything, open an issue
* If you feel comfortable about fixing the issue, fork the repo
* Commit to your local branch (which must be different from `master`)
* Submit your Pull Request (be sure to include tests and update documentation)
**[Back to top](#table-of-contents)**
### License

@@ -433,3 +494,1 @@

>THE SOFTWARE.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc