[web2py] Re: web2py sitting behind load balancer showing lb IP not client IP

2011-12-27 Thread Dave
I already said I can't change settings on the load balancer.  There is
no default route on this network so the traffic must be sourced from
the inside interface of the load balancer as it hits the web server.

Here's the problem:

diff -r 9619eb054669 gluon/globals.py
--- a/gluon/globals.py  Tue Dec 27 10:16:19 2011 -0600
+++ b/gluon/globals.py  Tue Dec 27 17:07:00 2011 -0500
@@ -548,7 +548,7 @@

 (record_id_name, table, record_id, unique_key) = \
 response._dbtable_and_field
-dd = dict(locked=False, client_ip=request.env.remote_addr,
+dd = dict(locked=False, client_ip=request.client.replace(':',
'.'),
   modified_datetime=request.now,
   session_data=cPickle.dumps(dict(self)),
   unique_key=unique_key)

The code for storing sessions on disk was using request.client which
checks http_x_forwarded_for before using remote_addr.  The code for
writing the session to database was just using remote_addr which was
always showing my private IP of the load balancer.  The above patch
should take care of it.

Thanks,
Dave

On Dec 23, 7:40 pm, pbreit pbreitenb...@gmail.com wrote:
 What web server are you running? On Nginx there's a module to take the
 x-forwarded-for and make it the client ip.

 http://wiki.nginx.org/HttpRealIpModule


[web2py] Re: web2py sitting behind load balancer showing lb IP not client IP

2011-12-23 Thread Dave
I can't make changes to the load balancer. The x-forwarded-for is
populated but I can not change the config so the source up is kept the
same. If I could, that would have been my first choice.

The network between the lb and web server isn't routed so the ip
source must be the local LAN RFC1018 address not the Internet source.

On Dec 23, 5:42 am, nils n...@olofsson.tv wrote:
 Hi, what load balancer are you using?
 Regards,
 Nils
 On Dec 23, 2011 5:17 a.m., Dave dave.st...@gmail.com wrote:







  Since I've moved my installation behind a load balancer all my session
  IP addresses show as the back-side IP of the load balancer, not the
  real client IP.

  Have any of you figured out a way to pull the {X-Forwarded-For} entry
  from the HTTP environment for the remote_addr instead?


[web2py] Re: web2py sitting behind load balancer showing lb IP not client IP

2011-12-23 Thread pbreit
What web server are you running? On Nginx there's a module to take the 
x-forwarded-for and make it the client ip.

http://wiki.nginx.org/HttpRealIpModule