Skip to content

Instantly share code, notes, and snippets.

@progrium
Created May 25, 2010 19:22
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 progrium/413565 to your computer and use it in GitHub Desktop.
Save progrium/413565 to your computer and use it in GitHub Desktop.
var http = require('http'), crypto = require('crypto'), fs = require('fs');
var server = http.createServer(function(request, response) {
request.headers['X-Forwarded-Proto'] = 'https';
request.headers['X-Forwarded-For'] = request.connection.remoteAddress;
var proxyRequest = http.createClient(80, 'localhost')
.request(request.method, request.url, request.headers);
request.addListener('data', function(data) { proxyRequest.write(data); });
request.addListener('end', function() { proxyRequest.end(); });
proxyRequest.addListener('response', function(proxyResponse) {
response.writeHead(proxyResponse.statusCode, proxyResponse.headers);
proxyResponse.addListener('data', function(data) { response.write(data); });
proxyResponse.addListener('end', function() { response.end(); });
});
});
server.setSecure(crypto.createCredentials({
key: fs.readFileSync("keyfile"),
cert: fs.readFileSync("certfile")
}));
server.listen(443);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment