Created
September 9, 2013 10:20
-
-
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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