1 var http = require('http')
2 , https = require('https')
3 , server = http.createServer(handler)
4 , port = +process.argv[2]
5 , prefix = process.argv[3]
6 , upstream = process.argv[4]
11 function handler (req, res) {
12 if (req.url.indexOf(prefix) != 0)
13 throw new Error('request url [' + req.url + '] does not start with [' + prefix + ']')
15 var upstreamUrl = upstream + req.url.substring(prefix.length)
16 console.log(req.url + ' -> ' + upstreamUrl)
17 https.get(upstreamUrl, function (ures) {
18 ures.on('end', function () {