The domain name accesses the node server through nginx proxy as follows:
www.xxx.com ---> 192.168.1.131:7819
How do I get this 7819 on the node server?
My current acquisition code is as follows:
app.use(function (req, res, next) {
var host = url.parse(req.headers.host).host;
})
In this case, there is no problem when accessing directly by IP.
If accessing by domain name, the domain name obtained by req.headers.host is directly the domain name
nginx configuration: b.t.wzhuanyun.com --> http://localhost:6120
Do you mean you want to get the port that the node is currently listening on?