Getting remote address

699 views
Skip to first unread message

the.anti.9

unread,
Oct 20, 2009, 1:39:31 AM10/20/09
to Tornado Web Server
How would i go about getting the IP Address that a request is coming
from?

Kelvin Kakugawa

unread,
Oct 20, 2009, 1:51:09 AM10/20/09
to python-...@googlegroups.com
The short answer is:
self.request.remote_ip

However, it depends on how your tornado server is setup. If your
tornado server is behind an nginx proxy, then you'll have to make sure
this line is set:
proxy_set_header X-Real-IP $remote_addr;

Refer to the example nginx configuration for the exact details.

Otherwise, if you're using another proxy, then you'll have to make
sure it passes the client's ip address in the X-Real-IP header.

-Kelvin

Алексей Силк

unread,
Dec 2, 2012, 6:45:29 AM12/2/12
to python-...@googlegroups.com
self.request.remote_ip

this helps in application? but how to set real IP in logs?

вторник, 20 октября 2009 г., 9:51:09 UTC+4 пользователь kelvin написал:

A. Jesse Jiryu Davis

unread,
Dec 2, 2012, 1:21:52 PM12/2/12
to python-...@googlegroups.com
I did this recently for my blog:

https://github.com/ajdavis/motor-blog/commit/877323bba801b9257090c99a181c86ac4f15fbc3

In nginx.conf:

proxy_set_header X-Real-IP $remote_addr;

In Python:

http_server = httpserver.HTTPServer(application, xheaders=True)

Aleksey Silk

unread,
Dec 2, 2012, 3:13:42 PM12/2/12
to python-...@googlegroups.com
Oooops ... sorry every body
I places xheaders=True in options dict but I should place it after
application() ...


С уважением, Алексей Силк
With best regards, Aleksey Silk

+7 (981) 849-12-36
ale...@silk.bz
skype - rootiks



2012/12/2 A. Jesse Jiryu Davis <je...@emptysquare.net>:
Reply all
Reply to author
Forward
0 new messages