mirror of
https://github.com/http-party/node-http-proxy.git
synced 2025-12-08 20:59:18 +00:00
ENH: updated README and added examples file.
This commit is contained in:
parent
edd8e2f04e
commit
07091b5077
29
README.md
29
README.md
@ -45,6 +45,24 @@ You can easily add a `pass` (stages) into both the pipelines (XXX: ADD API).
|
|||||||
|
|
||||||
In addition, every stage emits a corresponding event so introspection during the process is always available.
|
In addition, every stage emits a corresponding event so introspection during the process is always available.
|
||||||
|
|
||||||
|
#### Setup a basic stand-alone proxy server
|
||||||
|
|
||||||
|
var http = require('http'),
|
||||||
|
caronte = require('caronte');
|
||||||
|
//
|
||||||
|
// Create your proxy server
|
||||||
|
//
|
||||||
|
caronte.createProxyServer({target:'http://localhost:9000'}).listen(8000);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Create your target server
|
||||||
|
//
|
||||||
|
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);
|
||||||
|
|
||||||
#### Setup a stand-alone proxy server with custom server logic
|
#### Setup a stand-alone proxy server with custom server logic
|
||||||
|
|
||||||
``` js
|
``` js
|
||||||
@ -72,6 +90,17 @@ server.listen(5050);
|
|||||||
* Commit to your local branch (which must be different from `master`)
|
* Commit to your local branch (which must be different from `master`)
|
||||||
* Submit your Pull Request (be sure to include tests and update documentation)
|
* Submit your Pull Request (be sure to include tests and update documentation)
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
`caronte.createProxyServer` supports the following options:
|
||||||
|
|
||||||
|
* **target**: <url string to be parsed with the url module>
|
||||||
|
* **forward**: <url string to be parsed with the url module>
|
||||||
|
* **ssl**: object to be passed to https.createServer()
|
||||||
|
* **ws**: true/false, if you want to proxy websockets
|
||||||
|
* **xfwd**: true/false, adds x-forward headers
|
||||||
|
* **maxSock**: maximum number of sockets
|
||||||
|
|
||||||
### Test
|
### Test
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|||||||
15
examples/stand-alone.js
Normal file
15
examples/stand-alone.js
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
var http = require('http'),
|
||||||
|
caronte = require('caronte');
|
||||||
|
//
|
||||||
|
// Create your proxy server
|
||||||
|
//
|
||||||
|
caronte.createProxyServer({target:'http://localhost:9000'}).listen(8000);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Create your target server
|
||||||
|
//
|
||||||
|
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);
|
||||||
Loading…
x
Reference in New Issue
Block a user