problem with $_SERVER['REMOTE_ADDR']

前端 未结 3 2043
情话喂你
情话喂你 2021-01-16 11:56

i used $_SERVER[\'REMOTE_ADDR\'] and it returns client ip address (IP address from which the user is viewing the current page) but at now (and same code) it returns host ip

3条回答
  •  再見小時候
    2021-01-16 12:22

    @James @imez

    By default the client IP is in $_SERVER['REMOTE_ADDR']. When the user enters your site using a PROXY server (HTTP gateway) it tells you who it's proxing for (HTTP_X_FORWARDED_FOR) and will give it's own Proxy IP in $_SERVER['REMOTE_ADDR'].

    Anonymous proxies will omit HTTP_X_FORWARDED_FOR or simply lie to you.

    Knowing you have a real client IP isn't possible.

提交回复
热议问题