码迷,mamicode.com
首页 > 其他好文 > 详细

捕捉攻击者

时间:2015-01-08 17:21:38      阅读:137      评论:0      收藏:0      [点我收藏+]

标签:

pip install django-admin-honeypot

Add admin_honeypot to INSTALLED_APPS

url(r‘^admin/‘, include(‘admin_honeypot.urls‘, namespace=‘admin_honeypot‘)),
url(r‘^secret/‘, include(admin.site.urls)),

 生成数据库.捕捉攻击者

技术分享

技术分享

如果有使用代理的系统会记录127.0.0.1可通过设置中间件来实现

Why is the IP address logged as 127.0.0.1?

Django-admin-honeypot pulls the users IP address from the REMOTE_ADDR request header. If your Django app is behind a load balancer or proxy web server, this may not be set and instead you will instead have an HTTP_X_FORWARDED_FOR header which contains the IP address in a comma-separated string.

The simple solution is to use a middleware to automatically set REMOTE_ADDR to the value ofHTTP_X_FORWARDED_FOR, like so:

class RemoteAddrMiddleware(object):
    def process_request(self, request):
        if ‘HTTP_X_FORWARDED_FOR‘ in request.META:
            ip = request.META[‘HTTP_X_FORWARDED_FOR‘].split(‘,‘)[0].strip()
            request.META[‘REMOTE_ADDR‘] = ip

 

See also: http://docs.webfaction.com/software/django/troubleshooting.html#accessing-remote-addr

捕捉攻击者

标签:

原文地址:http://www.cnblogs.com/tuifeideyouran/p/4211230.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!