1

I have unmanaged VPS server. I am trying to get client IP form PHP $_SERVER['REMOTE_ADDR'] but it's always gives me same for all users that is server internal IP.

I have done some R & D and got firewall on server doing this, then I checked same on my another VPS server, but here it's giving correct client IP. Now I am sure there will be some configuration settings on my first VPS also that can give me correct client IP.

Please let me know what configuration I have to do on server to get this.

EDIT -

Once difference I have noted -

On VPS 1 where it's having non-standard ssh port 27560. Other can be accessed by port 22.I am not sure it this is creating problem here. Please suggest.

Hello Python
  • 23
  • 1
  • 4
  • contact your VPS provider. It is entirely possible that you are behind some sort of Load Balancer/proxy. as opposed to being directly connected to the internet. They should be able to tell you the config. without this information it will be very hard for us to figure out how to help. since the problem is most likely upstream from you.. – Doon Nov 13 '14 at 08:14

1 Answers1

1

Not sure what firewall you're using, but it sounds like it's proxying web traffic via itself. If it's acting as a proxy it may be setting the $_SERVER['HTTP_X_FORWARDED_FOR'] variable. If that's the case, you can check to see if that's set, and if it is, use that. Otherwise, fall back to the REMOTE_ADDR.

Note also, client IP can be faked fairly easily, so I hope it's not critical to get the IP correct in all cases (ie, I hope security in particular doesn't depend on this alone).

Jon Marnock
  • 264
  • 4
  • 12