The variable:
request.environ['REMOTE_ADDR']
always returns 127.0.0.1 for all requests when my Pyramid App is
deployed via Apache using ProxyPass
Snippet from httpd.conf:
<VirtualHost *:80>
ServerName www.example.com
ServerAlias example.com
# ----->>>> this is the line that I found useful:
SetEnvIf HTTP_X_FORWARDED_FOR (.*) REMOTE_ADDR=$1
ProxyRequests Off
ProxyPass / http://localhost:6543/ retry=5
ProxyPassReverse / http://localhost:6543/
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
</VirtualHost>
Snippet from a handler:
from pyramid_handlers import action
class AcctHandler(object):
def __init__(self, request):
self.request = request
def _getRemoteIP(self):
IP = self.request.environ.get('HTTP_X_FORWARDED_FOR')
if not IP:
IP = self.request.environ['REMOTE_ADDR']
return IP
Snippet from authentication.py, with intermediate lines excluded:
class AuthTktCookieHelper(object):
def remember(self, request, userid, max_age=None, tokens=()):
environ = request.environ
if self.include_ip:
remote_addr = environ['REMOTE_ADDR']
else:
remote_addr = '0.0.0.0'
Are the IP specific restraints or conditions from a client wholly
useless here, or is there something that I am obviously missing?
I found this AuthTktCookieHelper function when trying to figure out
how to set the max_age on a cookie.
I still have not yet figured out how to simply set the max_age value
for the cookie, from my login handler function.
[ remember(self.request, username) ]
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en.