Skip to content

Commit

Permalink
ENH: added new https example, needs to be simplified before merge
Browse files Browse the repository at this point in the history
updated existing example with log output
  • Loading branch information
srossross committed Sep 17, 2013
1 parent 13741a8 commit 427d8d8
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
54 changes: 54 additions & 0 deletions examples/https.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
var http = require('http')
, https = require('https')
, caronte = require('caronte')
;
//
// Create your proxy server
//
var options = {target:'https://google.com',
agent: new https.Agent({rejectUnauthorized:false}),
};

var proxyServer = caronte.createProxyServer(options);

proxyServer.ee.on('*:error', function(err, req, res){
res.end('There was an error proxying your request');
});

console.log("Proxy server listening on port 8000");
proxyServer.listen(8000);


//
// Create your proxy server
//
var options2 = {target:'https://google.com',
headers: {'host':'google.com'},
};

var proxyServer2 = caronte.createProxyServer(options2);

proxyServer2.ee.on('*:error', function(err, req, res){
res.end('There was an error proxying your request');
});

console.log("Proxy server 2 listening on port 8001");
proxyServer2.listen(8001);

//
// Create your proxy server
//
var options3 = {target:'https://google.com'};

var proxyServer3 = caronte.createProxyServer(options3);

proxyServer3.ee.on('*:error', function(err, req, res){
res.end('There was an error proxying your request');
});

console.log("Proxy server 3 listening on port 8002");
proxyServer3.listen(8002);




2 changes: 2 additions & 0 deletions examples/stand-alone.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ var http = require('http'),
//
// Create your proxy server
//
console.log("Proxy server listening on port 8000");
caronte.createProxyServer({target:'http://localhost:9000'}).listen(8000);

//
// Create your target server
//
console.log("Web server listening on port 9000");
http.createServer(function (req, res) {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.write('request successfully proxied!' + '\n' + JSON.stringify(req.headers, true, 2));
Expand Down

0 comments on commit 427d8d8

Please sign in to comment.