Skip to content

Commit ece85b4

Browse files
committed
[doc] update docs with toProxy option
1 parent 5251a23 commit ece85b4

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

README.md

+13-12
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
node-http-proxy
66
=======
77

8-
`node-http-proxy` is an HTTP programmable proxying library that supports
8+
`node-http-proxy` is an HTTP programmable proxying library that supports
99
websockets. It is suitable for implementing components such as
1010
proxies and load balancers.
1111

@@ -23,7 +23,7 @@ proxies and load balancers.
2323
### Core Concept
2424

2525
A new proxy is created by calling `createProxyServer` and passing
26-
an `options` object as argument ([valid properties are available here](lib/http-proxy.js#L34-L51))
26+
an `options` object as argument ([valid properties are available here](lib/http-proxy.js#L34-L51))
2727

2828
```javascript
2929
var httpProxy = require('http-proxy');
@@ -48,7 +48,7 @@ require('http').createServer(function(req, res) {
4848
Errors can be listened on either using the Event Emitter API
4949

5050
```javascript
51-
proxy.on('error', function(e) {
51+
proxy.on('error', function(e) {
5252
...
5353
});
5454
```
@@ -60,9 +60,9 @@ proxy.web(req, res, { target: 'http://mytarget.com:8080' }, function(e) { ... })
6060
```
6161

6262
When a request is proxied it follows two different pipelines ([available here](lib/http-proxy/passes))
63-
which apply transformations to both the `req` and `res` object.
63+
which apply transformations to both the `req` and `res` object.
6464
The first pipeline (ingoing) is responsible for the creation and manipulation of the stream that connects your client to the target.
65-
The second pipeline (outgoing) is responsible for the creation and manipulation of the stream that, from your target, returns data
65+
The second pipeline (outgoing) is responsible for the creation and manipulation of the stream that, from your target, returns data
6666
to the client.
6767

6868

@@ -93,14 +93,14 @@ and also you can put your own logic to handle the request.
9393
```js
9494
var http = require('http'),
9595
httpProxy = require('http-proxy');
96-
96+
9797
//
9898
// Create a proxy server with custom application logic
9999
//
100100
var proxy = httpProxy.createProxyServer({});
101101

102102
//
103-
// Create your custom server and just call `proxy.web()` to proxy
103+
// Create your custom server and just call `proxy.web()` to proxy
104104
// a web request to the target passed in the options
105105
// also you can use `proxy.ws()` to proxy a websockets request
106106
//
@@ -171,7 +171,7 @@ proxy.on('error', function (err, req, res) {
171171
res.writeHead(500, {
172172
'Content-Type': 'text/plain'
173173
});
174-
174+
175175
res.end('Something went wrong. And we are reporting a custom error message.');
176176
});
177177

@@ -251,7 +251,7 @@ var proxyServer = http.createServer(function (req, res) {
251251
});
252252

253253
//
254-
// Listen to the `upgrade` event and proxy the
254+
// Listen to the `upgrade` event and proxy the
255255
// WebSocket requests as well.
256256
//
257257
proxyServer.on('upgrade', function (req, socket, head) {
@@ -263,8 +263,8 @@ proxyServer.listen(8015);
263263

264264
### Contributing and Issues
265265

266-
* Search on Google/Github
267-
* If you can't find anything, open an issue
266+
* Search on Google/Github
267+
* If you can't find anything, open an issue
268268
* If you feel comfortable about fixing the issue, fork the repo
269269
* Commit to your local branch (which must be different from `master`)
270270
* Submit your Pull Request (be sure to include tests and update documentation)
@@ -273,7 +273,7 @@ proxyServer.listen(8015);
273273

274274
`httpProxy.createProxyServer` supports the following options:
275275

276-
* **target**: url string to be parsed with the url module
276+
* **target**: url string to be parsed with the url module
277277
* **forward**: url string to be parsed with the url module
278278
* **agent**: object to be passed to http(s).request (see Node's [https agent](http://nodejs.org/api/https.html#https_class_https_agent) and [http agent](http://nodejs.org/api/http.html#http_class_http_agent) objects)
279279
* **secure**: true/false, if you want to verify the SSL Certs
@@ -283,6 +283,7 @@ If you are using the `proxyServer.listen` method, the following options are also
283283
* **ssl**: object to be passed to https.createServer()
284284
* **ws**: true/false, if you want to proxy websockets
285285
* **xfwd**: true/false, adds x-forward headers
286+
* **toProxy**: passes the absolute URL as the `path` (useful for proxying to proxies)
286287

287288

288289
### Test

0 commit comments

Comments
 (0)