How does the node server get the port number of the incoming link?

  node.js, question

After the domain name passes through the nginx proxy, it accesses the node server as follows: —>

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

In this way, direct ip access will not be a problem.
If the domain name is accessed, what I get is the domain name directly


Configuration of nginx:>http://localhost:6120


What do you mean, do you want to get the port node is listening to?