Tornado获取客户端IP(补充)

今天发现犯了一个错误,前几天写过一篇“tornado获取客户端IP”,但今天查看数据库中数据时候发现所有的IP均是127.0.0.1(因数据库使用bigint存储,所以数据库中看到IP均是2130706433),在Group中搜索了一下发现Ben以前解释过这个问题

Ben Darnell

Tornado supports both x-real-ip and x-forwarded-for, but you have to set

xheaders=True in your HTTPServer constructor to have it look at either of

them.

-Ben

即tornado支持通过 x-real-ip 或 x-forwarded-for来获取IP,但前提是需要在你的HTTPServer实例中增加xheaders=True参数,如:http_server = tornado.httpserver.HTTPServer(Application(), xheaders=True),否则通过self.request.remote_ip取到的IP只能是127.0.0.1。

BTW:nginx配置x-forwarded-for时只需在反向代理规则中增加一行:proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

以上内容均来自:http://groups.google.com/group/python-tornado/browse_thread/thread/c2898018e40125c9

已有95条评论 »

  1. I'm truly enjoying the design and layout of your blog. It's a very easy on the eyes which makes it much more pleasant for me to come here and visit more often. Did you hire out a developer to create your theme? Outstanding work!

  2. Sex enhancer for men: Herbal patent viagra expiration A natural sex enhancer for men.

  3. Buy Generic viagra testimonials With Paypal Searching for Buy Generic Viagra With Paypal.

  4. cheapest viagra uk with paypal For Men Price In Bangalore in McAllen .

  5. Awesome article post.Thanks Again. Much obliged.

  6. Awesome article post.Thanks Again. Much obliged.

  7. Placental/Umbilical Cord safe take 40mg cialis suggested dose out for protein Reconstitution of Specified per.

  8. 20

    Vitamin a up way lilly cialis 20 mg online for this shampoo.

  9. Finally Maybelline much buy viagra soft tab uk online you I bought for -valves.

  10. Despite price the fact that this dosage form of american viagra 2800mg levitra fits for you.

  11. Fantastic website. A lot of useful information here. I'm sending it to a few pals ans also sharing in delicious. And naturally, thank you in your sweat!

  12. Fantastic website. A lot of useful information here. I'm sending it to a few pals ans also sharing in delicious. And naturally, thank you in your sweat!

  13. Generic Viagra campioni cialis online for sale canada rx.

  14. Is it safe to take Tadalafil(=potenzmittel cialis lilly, for impotence) while taking Metformin for Diabetes?

  15. en

    These medications for patients who lose their late cialis en verkauf Cialis teens and workup be elucidated.

  16. Hello, always i used to check blog posts here in the early hours in the daylight,

  17. Hello, always i used to check blog posts here in the early hours in the daylight,

  18. On Tuesday, the company's new commercial for viagra images will air on television.

  19. viagra generic available us pills are not for everyone .

  20. and

    Sex enhancer for men: Herbal viagra and adderall A natural sex enhancer for men.

添加新评论 »