0

I am working to build a web application that can direct various domain names to template sites in hapi / node. Any suggestions on how I might best set this up would be appreciated. What I've tried is below:

Server 1 has a web application with template websites at /site1, /site2 etc.

Server 2 is a proxy server to direct domains to their proper place. I attempted to use node-http-proxy (https://github.com/nodejitsu/node-http-proxy#setup-a-basic-stand-alone-proxy-server) but it does not support proxying to a specific path, only a url.

//does not work
{
  "domain1.com": "http://www.server1.com/site1,
  "domain2.com": "http://www.server1.com/site1,
  "domain3.com": "http://www.server1.com/site2
}
var server = http.createServer(function(req, res) {
    proxy.web(req, res, { target: endpoints[req.headers.host] });
});
Greg M
  • 125
  • 9
  • As clarification, I would want to maintain the url in the proxied request. So for instance, domain1.com/products would be proxied to http://www.server1.com/site1/products – Greg M Jan 17 '17 at 18:18
  • I have since discovered that you can pass an option in the proxy.web function ignorePath: true which allows you to specify a full URL. I am still interested in anyone has a better approach overall. Thanks. – Greg M Jan 17 '17 at 21:49

0 Answers0