日期:2014-05-16  浏览次数:20772 次

修改 apache源码 ,防流量 攻击用。 有高手可以指点吗。

  我想在 apache里面获取到客户的IP,然后自行处理 。哪位高手指点一下,我下载好了源码,可是找不到在哪里获取客户的IP。看的晕。
------解决方案--------------------
楼主想干什么?
但是我告诉你一种方案,可以不动apache源代码,你可以通过apache模块来做。
http://kimnote.com/category/opensource/apache/
方法
apxs -g -n ip
然后 修改下面代码

/* The sample content handler */
static int ip_handler(request_rec *r)
{
    if (strcmp(r->handler, "ip")) {
        return DECLINED;
    }
    r->content_type = "text/html";      
        ap_rprintf(r,"ip=[%s]",r->connection->remote_ip);
    if (!r->header_only)
        ap_rputs("The sample page from mod_ip.c\n", r);
    return OK;
}

修改httpd.conf
LoadModule ip_module modules/mod_ip.so
<Location /ip>
        SetHandler ip
</Location>
然后。
make
make install
make restart

http://127.0.0.1/ip

能看到你的ip吗?