SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Jan 2005
    Location
    PA
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    IP Logging behind Load Balancer

    My site is now behind a load balancer and $_SERVER['REMOTE_ADDR'] simply returns the IP of the zeus load balancer. Does anyone know of a way around this?

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    not sure if this will work, but print_r($_SERVER);

    there may be a forwarded-for or similar variable.

    however, its important to understand that your server receives this as an http header(if the variable is prefixed with HTTP_* then the var came from the http headers). clients can send the same http headers if they like, in an effort to lie about thier ip, or maybe the proxy they use is sending this header.

    im not sure if zeus can send this as a different/configurable named variable, or whether it will overwrite the clients header with its own should it receive one with the same name.

  3. #3
    SitePoint Addict
    Join Date
    Jul 2002
    Location
    Sooner Nation
    Posts
    208
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ju8st because I didnt find the answer anywhere on this forum, Ill show you the solution I have found.

    When using a load balancer I got these some additional header information
    HTTP_X_REAL_IP => XX.XXX.XXX.XX
    HTTP_X_FORWARDED_FOR => XX.XXX.XXX.XX

    So in order to get the real IP I used

    PHP Code:
    $_SERVER['HTTP_X_REAL_IP']; 
    The only function of business is to create customer value and to innovate. - Peter Drucker


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •