简体   繁体   中英

Point internet domain name to socketstream application/port

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM