Skip to content

Instantly share code, notes, and snippets.

@zerobase
Created September 9, 2013 10:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zerobase/6493850 to your computer and use it in GitHub Desktop.
Save zerobase/6493850 to your computer and use it in GitHub Desktop.
[nodejitsu/node-http-proxy#Proxying to HTTP from HTTPS](https://github.com/nodejitsu/node-http-proxy#proxying-to-http-from-https)
var fs = require('fs'),
https = require('https'),
httpProxy = require('http-proxy');
var options = {
https: {
key: fs.readFileSync('path/to/your/key.pem', 'utf8'),
cert: fs.readFileSync('path/to/your/cert.pem', 'utf8')
},
target: {
https: true // This could also be an Object with key and cert properties
}
};
//
// Create an instance of HttpProxy to use with another HTTPS server
//
var proxy = new httpProxy.HttpProxy({
target: {
host: 'example.com',
port: 443,
https: true
}
});
https.createServer(options.https, function (req, res) {
proxy.proxyRequest(req, res);
}).listen(8002);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment