Skip to content

Commit a980740

Browse files
author
fzheng
committed
editing readme
1 parent 9eb30b9 commit a980740

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

README.md

+26-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<img src="https://raw.github.com/nodejitsu/node-http-proxy/master/doc/logo.png"/>
33
</p>
44

5-
node-http-proxy
5+
node-http-proxy (revised by fzheng)
66
=======
77

88
`node-http-proxy` is an HTTP programmable proxying library that supports
@@ -234,6 +234,26 @@ httpProxy.createServer({
234234
}).listen(8014);
235235
```
236236

237+
#### Tracking the redirection
238+
```js
239+
//
240+
// Create a proxy server, and not allow redirection breaking the proxy
241+
//
242+
httpProxy.createProxyServer({
243+
agent : http.globalAgent,
244+
target: {
245+
protocol: 'http:',
246+
host: 'www1.macys.com'
247+
},
248+
headers: {
249+
host: 'www1.macys.com'
250+
},
251+
trapRedirect: {
252+
target: "localhost:8011"
253+
}
254+
}).listen(8011);
255+
```
256+
237257
Also you can proxy the websocket requests just calling the `ws(req, socket, head)` method.
238258

239259
```js
@@ -285,6 +305,11 @@ If you are using the `proxyServer.listen` method, the following options are also
285305
* **xfwd**: true/false, adds x-forward headers
286306
* **toProxy**: passes the absolute URL as the `path` (useful for proxying to proxies)
287307

308+
If you would like to track redirection and not allow it breaking your reverse proxy, the following options are also applicable:
309+
310+
* **trapRedirect**: object to be passed to http(s).request
311+
* **trapRedirect.source** (optional): the source domain/url of the redirection starts, by default, **target.domain** or **headers.domain** will be used
312+
* **trapRedirect.target**: the target domain/url you wish the redirection go instead
288313

289314
### Test
290315

0 commit comments

Comments
 (0)