How to set http_x_forwarded_for to remote_addr

Discussion in 'PHP' started by zaint, Nov 10, 2013.

  1. #1
    I have 2 hosting that give me different information about IP and Proxy ,
    e.g , My IP : 111.22.33.44 and My Proxy : 123.45.67.89

    in hostinger.com

    $_SERVER["REMOTE_ADDR"]=123.45.67.89
    $_SERVER["HTTP_X_FORWARDED_FOR"]=111.22.33.44
    but

    in hawkhost.com

    $_SERVER["REMOTE_ADDR"]=111.22.33.44
    $_SERVER["HTTP_X_FORWARDED_FOR"]=123.45.67.89


    Do you know? why is this different?
    Thank You...
     
    zaint, Nov 10, 2013 IP
  2. ThePHPMaster

    ThePHPMaster Well-Known Member

    Messages:
    737
    Likes Received:
    52
    Best Answers:
    33
    Trophy Points:
    150
    #2
    Hawkhost.com seems to have it incorrectly set.

    If you are behind a proxy, HTTP_X_FORWARDED_FOR should return the actual client IP. It is the general knowldge (IETF even had a draft on it). Here is more on the variable and its content:

    http://en.wikipedia.org/wiki/X-Forwarded-For
     
    ThePHPMaster, Nov 10, 2013 IP