I have a apache server and configure some vhosts.
Apache server with ip 172.20.20.20.
A domain url is 'http://www.atest.com/' and another domain url is 'http://www.btest.com/'
In test enviroment, I use firefox with 'Switchhost' plug-in to access Domain A and Domain B.
It works well.
The problem is how can I make a http request by node.js?
my code is here:
var options = {
host: 'http://www.atest.com/',
port: 80,
path: '/msg/putMsg',
method: 'POST'
};
var req = http.request(options, function(res){
var data = '';
res.setEncoding('utf8');
res.on('data', function(chunk){
data += chunk;
});
res.on('end', function(){
});
});
req.on('error', function(err){
console.log('problem with request: ' + e.message);
});
req.write(msg);
req.end();
}
this code snippet works to post some message to Domain A, but dns doesn't work.
Try adding
172.20.20.20 www.atest.com atest.com www.btest.com btest.com
to your hosts file (/etc/hosts on Linux /private/etc/hosts on OSX)
http://en.wikipedia.org/wiki/Hosts_(file)#Location_in_the_file_system has locations of the hosts file for other platforms.