I am looking for guidelines for pointing 3 internet domains to 3 different socketstream 3.x applications.
Lets say i have three ss apps running,
99.99.99.1:4010, 99.99.99.1:4020, 99.99.99.1:4030
and i own 3 domains
www.myfirstdomain.com, www.myseconddomain.com, www.mythirddomain.com
What is the recommended approach for routing the domains to the applications? Somehow make ss recognize url headers or something? Three different ips on server? I probably need some routing module for node? What to change in ss /app.js ?
Thank you in advance !
You can achieve this by using a HTTP proxy, either using NGINX, or if you prefer using a Node.js-based solution, using the bouncy npm module https://github.com/substack/bouncy, or the node-http-proxy module https://github.com/nodejitsu/node-http-proxy.
An example relating to your case could be this:
var bouncy = require('bouncy');
var server = bouncy(function (req, res, bounce) {
if (req.headers.host === 'www.myfirstdomain.com') {
bounce(4010);
}
else if (req.headers.host === 'www.myseconddomain.com') {
bounce(4020);
}
else if (req.headers.host === 'www.myseconddomain.com') {
bounce(4030);
}
else {
res.statusCode = 404;
res.end('no such host');
}
});
server.listen(80);