DELAEMON BLOG

Live as if you were to die tomorrow. Learn as if you were to live forever.

Apache Module IPを表示

ひな形つくってモジュールとディレクトリの紐付け済みでmod_xx.cを以下に編集

// ~ 省略
#include "http_core.h"

/* The sample content handler */
static int ip_handler(request_rec *r)
{
    const char *remotehost = NULL;

    if (strcmp(r->handler, "ip")) {
        return DECLINED;
    }
    r->content_type = "text/html";

    if (!r->header_only) {
        remotehost = ap_get_remote_host(r->connection, r->per_dir_config, REMOTE_NAME, NULL);
        ap_rprintf(r, "IP:%s", remotehost);
    }
    return OK;
}

参考にしたページ
http://opensource.apple.com/source/apache/apache-643/apache/src/modules/standard/mod_access.c