Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get client IP address in Azure Functions node.js?

I have an Azure function written on node.js. How could I retrieved an IP address of a client that called the function?

What I've found so far:

  1. An answer to the same question, but using C#.
  2. It is possible to read it from headers:

    module.exports = function (context, req) {
        var ip = req.headers['x-forwarded-for']    
    }
    

Is it reliable to get the ip this way, since it can be easily changed on the way to the function?

like image 695
Eskandar Avatar asked Jun 19 '17 15:06

Eskandar


1 Answers

Yes it is reliable, because Azure web server will overwrite x-forwarded-for as it knows it is forwarding from load balancer.

like image 92
Akash Kava Avatar answered Oct 10 '22 03:10

Akash Kava