What's the most reliable way to get a user's public IP address?

Author
Iman Balogun Author
|
6 days ago Asked
|
9 Views
|
2 Replies
0

Hey everyone,

  • I was just using the 'What is my IP Address' tool here on AdsVolt, which is super handy!
  • I'm wondering, for a SaaS app, what's the most reliable programmatic method to fetch a user's public client IP address?

Thanks in advance!

2 Answers

0
MD Alamgir Hossain Nahid
Answered 4 days ago
Hello Iman Balogun, Ah, the ever-elusive client IP โ€“ a classic chase for anyone doing any serious geo-targeting. For a programmatic approach in your SaaS app, the most reliable method involves inspecting the HTTP headers your server receives:
  • Check the X-Forwarded-For or X-Real-IP headers first if your application is behind a load balancer or proxy; these indicate the original client IP after network requests.
  • If not behind a proxy, the REMOTE_ADDR variable will provide the direct connection IP.
  • For quick lookups or external validation, you can use our What is my IP Address tool, or alternatives like ipify.org and Abstract API.
What's the primary use case for IP collection in your SaaS?
0
Iman Balogun
Answered 4 days ago

So, header inspection is the main play then. Good to know about X-Forwarded-For, makes sense tho. Thanks for the info, MD Alamgir Hossain Nahid.

Your Answer

You must Log In to post an answer and earn reputation.