I own two domains, abc.com and xyz.com (not the real ones I own, but they work as an example). They both point to the same ip address. The following is my server js file:
var sys=require('sys'),
http=require('http'),
settings=require('./settings');
var srv = http.createServer(function(req, res) {
var body="<b>Hello World!</b>"
res.writeHead(200, {
'content-length': body.length,
'content-type': 'text/html',
'stream': 'keep-alive',
'accept': '*/*'
}
);
res.end(body);
});
srv.listen(8000, 'abc.com' ); // (settings.port, settings.hostname);
I then visit http://abc.com:8000/ and http://xyz.com:8000/ and they both display the webpage. I thought that I would only be able to see the page on abc.com since that's what I set as the hostname.
However, when I put '127.0.0.1' as the hostname, then I can only view the page via wget on the server itself.
So what does the hostname parameter do?