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

已有65条评论 »

  1. Hello! payday loans online , generic cialis , viagra from india , cialis online pharmacy ,

  2. Hello! online viagra , online cialis , online viagra , viagra generic , online cialis ,

  3. Hello! cash advance cabelas visa , loan satisfaction form , original viagra verpackung , payday loans in amory ms ,

  4. Hello! personal loans , direct lenders for payday loans , generic viagra online ,

  5. Hello! viagra soft tabs , sildenafil generic india ,

  6. Hello! cheap viagra ,

  7. Hello! cheap cialis , order cialis ,

  8. Hello! buy generic viagra online , online cialis , buy viagra online ,

  9. Hello! buy cialis online , canadian viagra , generic viagra , generic viagra ,

  10. Hello! instant payday loans , generic viagra , buy cialis online , personal loan ,

  11. Hello! quick cash , payday loans advance , viagra professional , cialis cheap ,

  12. Hello! cialis cod ,

  13. Hello! buy cialis online|buy cialis|cialis generic|generic cialis|cialis online|cilais price|cheap cialis|cialis cheap|order cialis , viagra| buy viagra| viagra online| generic viagra online| viagra coupon| buy viagra online| generic viagra| cheap viagra| order viagra| buy generic viagra| cheap viagra online , buy cialis online|buy cialis|cialis generic|generic cialis|cialis online|cilais price|cheap cialis|cialis cheap|order cialis , viagra| buy viagra| viagra online| generic viagra online| viagra coupon| buy viagra online| generic viagra| cheap viagra| order viagra| buy generic viagra| cheap viagra online , buy cialis online|buy cialis|cialis generic|generic cialis|cialis online|cilais price|cheap cialis|cialis cheap|order cialis ,

  14. Hello! cheap viagra , cash advance online , payday loan or pay day loan , cialis cheap , canadian viagra generic ,

  15. https://www.idshome.cc/rhode-island-ri-fake-ids-p-7.html https://www.idshome.cc/south-carolina-sc-fake-ids-p-8.html https://www.idshome.cc/

  16. Hello! online viagra , cialis without a doctors prescription , cheap viagra , viagra cheap ,

  17. Hello! cheap viagra online , generic cialis ,

  18. Hello! buy cialis , cialis , cialis online , order viagra , viagra soft flavoured ,

  19. Hello! online cialis ,

  20. Hello! viagra generic ,

添加新评论 »