Created
February 28, 2012 21:34
-
-
Save amir20/1935306 to your computer and use it in GitHub Desktop.
A rails proxy written in node.js for testing assets. No need for apache.
This file contains 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
{ | |
"name": "rails-proxy", | |
"version": "0.0.1", | |
"dependencies": { | |
"http-proxy": "*", | |
"node-static": "*" | |
}, | |
"engines": { "node": ">= 0.4.4" } | |
} |
This file contains 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 httpProxy = require('http-proxy') | |
, static = require('node-static') | |
var file = new(static.Server)('./public/assets'); | |
require('http').createServer(function (request, response) { | |
request.addListener('end', function () { | |
console.log("Fetching /assets/" + request.url); | |
file.serve(request, response); | |
}); | |
}).listen(7000); | |
console.log("Starting asset static server on port 7000"); | |
var options = { | |
router: { | |
'localhost/assets': '0.0.0.0:7000', | |
'localhost': '0.0.0.0:3000' | |
} | |
}; | |
var proxyServer = httpProxy.createServer(options).listen(8080); | |
console.log("Listening on port 8080 and forwarding all requests to 0.0.0.0:3000"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment