I need to be able to offer replica sites (to www.google.com, www.facebook.com, etc. any site) through my node server. I found this library:
https://github.com/nodejitsu/node-http-proxy
And I used the following code when proxying requests:
options = {
ignorePath: true,
changeOrigin: false
}
var proxy = httpProxy.createProxyServer({options});
router.get(function(req, res) {
proxy.web(req, res, { target: req.body.url });
});
However, this configuration always causes me error for mostly any site. Depending on the site, I'll get an "Unknown service" error coming from the target url, or an "Invalid host"... something along those lines. However, when I do
changeOrigin: true
I get a functioning proxy service, but my the user's browser gets redirected to the actual url of their request, not to mine (so if req.body.url = http://www.google.com, the request will go to http://www.google.com)
How can I make it so my site's url gets shown, but so that I can exactly copy whatever is being displayed? I need to be able to add a few JS files to the request, which I'm doing using another library.
via db2791
No comments:
Post a Comment