Alpha Video Training
Results 1 to 10 of 10

Thread: Tracking user IP through a load balancer

  1. #1
    "Certified" Alphaholic mikeallenbrown's Avatar
    Real Name
    Mike Brown
    Join Date
    Nov 2009
    Location
    United States
    Posts
    1,879

    Default Tracking user IP through a load balancer

    I use request.remote_addr to get the users IP address. That worked great when I was running only one server. Now I have three with a load balancer. The IP address that is returned now is that of the server the user is pointed to by the load balancer. Question is: How can I get the users IP address now that I am using load balancers?
    Last edited by mikeallenbrown; 03-24-2014 at 09:15 PM. Reason: meant to say 'request.remote_addr'
    Mike Brown - Contact Me
    Programmatic Technologies, LLC
    Programmatic-Technologies.com
    Independent Developer & Consultant

  2. #2
    Volunteer Moderator Steve Wood's Avatar
    Real Name
    Steve Wood
    Join Date
    Nov 2003
    Location
    Bay Area, California
    Posts
    8,842

    Default Re: Tracking user IP through a load balancer

    Do you mean request.remote_addr? Either way, maybe you can grab request.body on a test a5w page to a text file and study what you get from different users.

    <%a5
    cc = request.body
    save_to_file(cc,"c:\cc.txt")
    %>
    Steve Wood
    Join the ALPHA DEVELOPERS NETWORK
    There is no Cloud. It's just someone else's computer.
    Web - Mobile - Hosting - Products - Frameworks - Developer Resources
    AlphaToGo | IADN (100% Alpha Anywhere Websites)

  3. #3
    "Certified" Alphaholic mikeallenbrown's Avatar
    Real Name
    Mike Brown
    Join Date
    Nov 2009
    Location
    United States
    Posts
    1,879

    Default Re: Tracking user IP through a load balancer

    Ahh....yes, I meant request.remote_addr.
    Mike Brown - Contact Me
    Programmatic Technologies, LLC
    Programmatic-Technologies.com
    Independent Developer & Consultant

  4. #4
    "Certified" Alphaholic mikeallenbrown's Avatar
    Real Name
    Mike Brown
    Join Date
    Nov 2009
    Location
    United States
    Posts
    1,879

    Default Re: Tracking user IP through a load balancer

    Quote Originally Posted by Steve Wood View Post
    Do you mean request.remote_addr? Either way, maybe you can grab request.body on a test a5w page to a text file and study what you get from different users.

    <%a5
    cc = request.body
    save_to_file(cc,"c:\cc.txt")
    %>
    Tried this this morning. Request.body doesn't seem to do anything. The CC file is generated but it's empty.
    Mike Brown - Contact Me
    Programmatic Technologies, LLC
    Programmatic-Technologies.com
    Independent Developer & Consultant

  5. #5
    "Certified" Alphaholic peteconway's Avatar
    Real Name
    Peter Conway
    Join Date
    Oct 2005
    Location
    Melbourne, Australia
    Posts
    2,638

    Default Re: Tracking user IP through a load balancer

    Hi Mike - just wondering - what load balancer are you using and how do you find its performance? - and hi Steve.
    Peter
    Insanity: doing the same thing over and over again and expecting different results.
    Albert Einstein, (attributed)
    US (German-born) physicist (1879 - 1955)

  6. #6
    Volunteer Moderator Steve Wood's Avatar
    Real Name
    Steve Wood
    Join Date
    Nov 2003
    Location
    Bay Area, California
    Posts
    8,842

    Default Re: Tracking user IP through a load balancer

    I should have said try request.raw. body is the result of a POST and that is what I use most often in programming. Raw is everything. Check the Alpha documentation for "request" to find other request variables. - and Hi Peter
    Steve Wood
    Join the ALPHA DEVELOPERS NETWORK
    There is no Cloud. It's just someone else's computer.
    Web - Mobile - Hosting - Products - Frameworks - Developer Resources
    AlphaToGo | IADN (100% Alpha Anywhere Websites)

  7. #7
    "Certified" Alphaholic mikeallenbrown's Avatar
    Real Name
    Mike Brown
    Join Date
    Nov 2009
    Location
    United States
    Posts
    1,879

    Default Re: Tracking user IP through a load balancer

    Quote Originally Posted by peteconway View Post
    Hi Mike - just wondering - what load balancer are you using and how do you find its performance? - and hi Steve.
    Peter
    We use RackSpace for our hosting needs. Very happy with their service. The load balancer is their proprietary software. Seems to work just fine. No complaints.
    Mike Brown - Contact Me
    Programmatic Technologies, LLC
    Programmatic-Technologies.com
    Independent Developer & Consultant

  8. #8
    "Certified" Alphaholic mikeallenbrown's Avatar
    Real Name
    Mike Brown
    Join Date
    Nov 2009
    Location
    United States
    Posts
    1,879

    Default Re: Tracking user IP through a load balancer

    Quote Originally Posted by Steve Wood View Post
    I should have said try request.raw. body is the result of a POST and that is what I use most often in programming. Raw is everything. Check the Alpha documentation for "request" to find other request variables. - and Hi Peter
    Ah, I see. I'll try 'RAW' tomorrow morning. Thanks.
    Mike Brown - Contact Me
    Programmatic Technologies, LLC
    Programmatic-Technologies.com
    Independent Developer & Consultant

  9. #9
    "Certified" Alphaholic
    Real Name
    Frank Bicknell
    Join Date
    Feb 2010
    Location
    39.1915° N, 84.4348° W
    Posts
    2,467

    Default Re: Tracking user IP through a load balancer

    Quote Originally Posted by mikeallenbrown View Post
    I use request.remote_addr to get the users IP address. That worked great when I was running only one server. Now I have three with a load balancer. The IP address that is returned now is that of the server the user is pointed to by the load balancer. Question is: How can I get the users IP address now that I am using load balancers?
    It seems to me that Alpha is not getting the users IP so how can any Alpha function work? Probably going to have to get the users ip forwarded from the load balancer software.
    Win 10 64 Development, Win 7 64 WAS 11-1, 2, Win 10 64 AA-1,2, MySql, dbForge Studio The Best MySQL GUI Tool IMHO. http://www.devart.com/dbforge/mysql/studio/

  10. #10
    Alpha Software Employee Lenny Forziati's Avatar
    Real Name
    Lenny Forziati
    Join Date
    Nov 2001
    Location
    Alpha Software
    Posts
    4,695

    Default Re: Tracking user IP through a load balancer

    As Frank mentioned, the issue is that the user does not connect to the server directly. Instead it connects to the load balancer, and then the load balancer connects to the server. This means that all the server knows is that a connection was initiated from the load balancer.

    Talk to RackSpace about their load balancer options. Some have the ability to spoof the source IP address so it looks like the real client to the server. Others can set an optional header with the actual source IP address and you can read that value from Xbasic. X-Forwarded-For is a header used by many balancers and proxies to make the original source address available. You could easily read this header from your code.
    Last edited by Lenny Forziati; 04-03-2014 at 12:15 PM.

    Lenny Forziati
    Vice President, Internet Products and Technical Services
    Alpha Software Corporation

Similar Threads

  1. Tracking user logins for a web app
    By Mike Reed in forum Code Archive
    Replies: 13
    Last Post: 08-15-2017, 06:18 PM
  2. Reports, Report Server, and Load Balancer
    By Steve Workings in forum Application Server Version 11 - Web/Browser Applications
    Replies: 3
    Last Post: 12-01-2012, 09:12 AM
  3. Strategy for user sign off activity tracking
    By Mike Wilson in forum Database Design
    Replies: 2
    Last Post: 12-16-2010, 10:15 PM
  4. Tracking User Activity in an Application
    By gobbligook in forum Application Server Version 9 - Web/Browser Applications
    Replies: 11
    Last Post: 05-17-2010, 05:20 PM
  5. User Logon Tracking
    By iandsdb in forum Application Server Version 9 - Web/Browser Applications
    Replies: 8
    Last Post: 11-29-2009, 04:22 AM

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
  •