• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
proxy_ips or Why does every visitor to my website have the same IP address?

I'm using ci_sessions with the databse option.
I'm on a clustered hosting solution.
ci_sessions is working, but every visitor to my website have the same IP address???
My hosting provider say if I want to get correct client IP address, I need to replace REMOTE_ADDR with: HTTP_X_FORWARDED_FOR

How can I do this in CI? What's the best way?
WIll using proxy_ips in my config file work? If so, how do I use it?

The HTTP_X_FORWARDED_FOR is not part of the standard, so there's no guarantee that a proxy will send that header, or that it will be accurate. Wikipedia mentions checking the proxy server against a whitelist, but this woould require you to also know which proxies send the header honestly.

I don't think relying on the IP address for sessions is ever recommended. Not only do you run into problems like your proxy issue, but an IP address is easily spoofed. I'm not great with sessions, but I would think just getting a GUID as the session identifier would be better. Store it in a cookie or something.

Any more ideas from the ether?

Ask your host why you should have to do that, when it works properly for everyone else, and tell them you're using a framework.

CodeIgniter is built to run on virtually any server, if the server can't run CodeIgniter properly (with just a bit of configuration), it might be time to find a better host.

Just out of interest, what IP address do you get? Is it an internal IP?

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.