0

I am trying to get client IP in php I am facing two issues-

  1. I am getting public IP in HTTP_X_FORWARD_FOR.Is it different from HTTP_X_FORWARDED_FOR?
  2. I am not able to get correct IP address in REMOTE_ADDR.
Manik
  • 264
  • 2
  • 8
  • 1
    _"I am not able to get correct IP address in REMOTE_ADDR."_ - probably because you are getting it in HTTP_X_FORWARD_FOR. Those "alternatives" get explicitly provided in cases where there is a proxy involved or something like that - _because_ REMOTE_ADDR would be the proxy's IP in such a case. – CBroe Jul 05 '22 at 11:18
  • 1
    My guess is that `HTTP_X_FORWARD_FOR` the same is as `HTTP_X_FORWARDED_FOR`, but just spelled differently. – KIKO Software Jul 05 '22 at 11:20
  • Using these headers has security implications because they can be set to anything by the client. Please see https://stackoverflow.com/a/55790/369143 – Bram Verstraten Jul 05 '22 at 11:33
  • @CBroe so should I retrieve IP from HTTP_X_FORWARDED_FOR if there is some proxy or what should I do? – Manik Jul 05 '22 at 11:34
  • https://stackoverflow.com/a/55790/1427878 – CBroe Jul 05 '22 at 11:34
  • @BramVerstraten I read it and i think there is nothing more specific we can do for proxy – Manik Jul 05 '22 at 11:47

0 Answers0