File tree 1 file changed +26
-1
lines changed
1 file changed +26
-1
lines changed Original file line number Diff line number Diff line change 2
2
<img src =" https://raw.github.com/nodejitsu/node-http-proxy/master/doc/logo.png " />
3
3
</p >
4
4
5
- node-http-proxy
5
+ node-http-proxy (revised by fzheng)
6
6
=======
7
7
8
8
` node-http-proxy ` is an HTTP programmable proxying library that supports
@@ -234,6 +234,26 @@ httpProxy.createServer({
234
234
}).listen (8014 );
235
235
```
236
236
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
+
237
257
Also you can proxy the websocket requests just calling the ` ws(req, socket, head) ` method.
238
258
239
259
``` js
@@ -285,6 +305,11 @@ If you are using the `proxyServer.listen` method, the following options are also
285
305
* ** xfwd** : true/false, adds x-forward headers
286
306
* ** toProxy** : passes the absolute URL as the ` path ` (useful for proxying to proxies)
287
307
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
288
313
289
314
### Test
290
315
You can’t perform that action at this time.
0 commit comments