Home > front end >  Using IIS to serve Node/Express API with Reverse Proxy. Problems getting IP client's IP address
Using IIS to serve Node/Express API with Reverse Proxy. Problems getting IP client's IP address

Time:01-29

I have a node application that is being served by IIS. I followed this guide and it its all working perfectly:

https://dev.to/petereysermans/hosting-a-node-js-application-on-windows-with-iis-as-reverse-proxy-397b

Im having an issue I understand why its happening with the IP address (because of reverse routing, NODE its tracking 127.0.0.1 instead of the client's IP).

At Node, Im getting the IP as follows:

const ipAddress = req.socket.remoteAddress;

Is there a way from Node to identify the IP address that is hitting IIS?

Thanks.

CodePudding user response:

If you are reverse proxying, you can do this:

const ipAddress = req.headers['x-forwarded-for'] || req.socket.remoteAddress

  •  Tags:  
  • Related