Here is my understanding of the user's IP:
User's IP is REMOTE_ADDR
. But if the user is using a proxy (like HotSpotSheild (HSS)) or a chain of proxies, then REMOTE_ADDR
is the address of the proxy (not user's IP), and the user's IP might be in the other headers like these:
HTTP_CLIENT_IP
HTTP_X_FORWARDED_FOR
HTTP_X_FORWARDED
HTTP_X_CLUSTER_CLIENT_IP
HTTP_FORWARDED_FOR
HTTP_FORWARDED
- Or maybe none of them.
So when an user uses the proxy, then he is undetectable.
Question1: Always one of those headers (above) is full? And are the rest empty?
Question2: Is that a good idea that I store both REMOTE_ADDR
and one of those header (which isn't empty) in different fields in the database? (I mean having two separated columns for the IP, not just one column)
Here is my understanding of a load balancer:
It is a reverse proxy server that you use when you're running a cluster of servers. Clients connect to the load balancer, and it forwards the connection to one of the actual servers.
Theory:
If you use a load balancer, use
HTTP_X_FORWARDED_FOR
as user's IP.
Question3
Why should I store bHTTP_X_FORWARDED_FOR
as the user's IP when there is a load balancer? I mean what's bHTTP_X_FORWARDED_FOR
to do with load balancer?