Is there a way to find IP address?
Damjan
gdamjan at gmail.com
Sun Sep 17 14:34:07 EDT 2006
>> Normaly I can log user's IP address using os.environ["REMOTE_ADDR"] .
>> If a user is behind a proxy, I will log proxy's IP address only.
>> Is there a way how to find a real IP user's address?
>
> os.environ["HTTP_X_FORWARDED_FOR"]
>
> (but that can easily be spoofed, and is mostly meaningless if the user
> uses local IP addresses at the other side of the proxy, so you should
> use it with care)
Yep, you should only use "HTTP_X_FORWARDED_FOR" if you trust the proxy and
you check that the request is indeed coming from it
(if environ["REMOTE_ADDR"] in proxy_list).
--
damjan
More information about the Python-list
mailing list