I have a basic http server that runs on a server where multiple domains point to. I need to find the host of the request (the domain where the request is coming from).
require("http").createServer(function (req, res) {
console.log(req.headers.host);
res.end("Hello World!");
}).listen(9000);
req.headers.host's value is 127.0.0.1:9000 instead of the domain name (example.com or so).
How can I get the domain name from request object?
The node server is proxied via nginx. The configuration is like this:
server {
listen 80;
server_name ~.*;
location / {
proxy_pass http://127.0.0.1:9000;
}
}