If the reason you want to know the clientโs IP address is really important, twist it all up.
Any of these header values โโcan be faked freely.
REMOTE_ADDR is the only truly reliable information, as it is transmitted to you by your web server, which processes the request. Theoretically, you can falsify , but it is much more complicated than faking the value of the header and a completely different attack class.
There are exceptions in very, very specific hosting environments behind reverse proxies. In these cases, the person managing this proxy will be able to indicate which header value you need to check.
Pekka ์
source share