Skip to content

Instantly share code, notes, and snippets.

@DTrejo
Created April 10, 2011 00:26
Show Gist options
  • Save DTrejo/911927 to your computer and use it in GitHub Desktop.
Save DTrejo/911927 to your computer and use it in GitHub Desktop.
has a problem
var http = require('http')
, httpProxy = require('http-proxy')
, ns = require('node-static')
, file = new(ns.Server)('./public')
, url = require('url')
, querystring = require('querystring')
;
//
// Create a proxy server with custom application logic
//
// httpProxy.createServer(function (req, res, proxy) {
// // proxy.proxyRequest(req, res, 80, 'flickr.com');
// }).listen(8000);
httpProxy.createServer(function (request, response, proxy) {
request.addListener('end', function () {
var parsed = url.parse(request.url)
, params = querystring.parse(parsed.query)
;
if (params.p) {
console.log('bang!');
proxy.proxyRequest(request, response, 80, 'flickr.com');
} else {
file.serve(request, response);
}
});
}).listen(8000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment