I am running cherrypy 2.2 (turbogears) behind apache 2,
using apache
for static content. In this configuration, the value
cherrypy.request.remote_addr is always 127.0.0.1.
The documents suggest two solutions:
use cherrypy.request.header['X-Forwarded-For'] to get the
'true'
client ip.
It seems unpythonic to litter my source by replacing every
call to
cp.request.remote_addr with something like:
xff = cherrypy.request.header['X-Forwarded-For']
ip = xff.split(',')[0].strip() or
cherrypy.request.remote_addr
In particular, if I start using other modules, (i use the
uploadfilter
found at http://docs.turbogears.org/1.0/FileUploadProgressBar.)
it
seems unwise to start mucking about with the xff
replacement.
Some docs also suggest the following settings for app.cfg:
baseUrlFilter.on = True
baseUrlFilter.use_x_forwarded_host = True
tools.proxy.on = True
The exact settings seems to change from version to verison.
I have
experiments with base_url_filter and baseurl_filter, and put
the
settings under [/] and [global].
None of the settings had any effect on
cp.request.remote_addr. Do I
have a the wrong settings, or am I misinterpreting their
effects? The
documentation on the official site seems a bit quiet on the
subject,
is there a better place (in the source) that explains the
effects?
As a workaround, I am considering creating a filter that
will alter
request.remote_addr. I wanted to check with the experts in
the group
to make sure I haven't got simpler solution, or create
unintentional
side effects with the filter.
Thanks!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|