I am looking to create multiple sites on a single server running node.js. Three of the sites could be easily served by running a file based server such as http-server but there are other sites which will be web services based, so just creating a single http-server with multiple directories for each site is not an option.
Does node-http-proxy combined with http-server work best for this case, or is there a better way?
My thought was to set up node-http-proxy as:
- www.site1.com -> http://localhost:3000
- www.site2.com -> http://localhost:3001
- www.site3.com -> http://localhost:3002
- www.site4.com -> http://localhost:3003
Then create multiple instances of http-server listening on each of the 4 ports.
- http-server site1 (on port 3000)
- http-server site2 (on port 3001)
- http-server site3 (on port 3002)
- myWebService (on port 3003)
Is this the proper approach?
Are there any advantages/disadvantages of doing it this way over just coding a custom node.js listener that determines what to do for each of the sites without forwarding the requests to another listening node server?
i.e. Does the reverse proxy add a lot of overhead? Does creating multiple http-server instances incur additional cpu overhead? etc.
Is there a better way??
via user3072517
No comments:
Post a Comment