How to get client ip from node.js express application deployed on AWS Elastic beanstalk?

Question:

I am using elastic beanstalk with ngnix proxy server. my application code was on node.js express framework. I am trying to access client ip via following code

but i always getting same client ip for all incoming request. I think it will be the proxy server’s ip address.

How to access real client address from my application???

Answer:

I defer with @austince, the Client IP will be the first entry in the list for Elastic Beanstalk.

Example:

X-Forwarded-For: 182.12.12.123, 78.13.13.123

In case anyone, come looking for example code, here is what I have used in my project.

Leave a Reply