nginx - How does the node server obtain the port number of the incoming link?
为情所困
为情所困 2017-05-16 17:15:42
0
1
487

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

为情所困
为情所困

reply all(1)
習慣沉默

Do you mean you want to get the port that the node is currently listening on?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template