トップ «年末年始のアクセス増加 / 高負荷対策 / NFSに関す.. 最新 Pound を選択した理由 / Apache のパフォー..»

PC関係のメモ


ReverseProxy を使う場合のアクセス解析 / Esehttpdをインストール

ReverseProxy を使う場合のアクセス解析

リバースプロキシ(Pound)を使うとアクセスログに記録されるリモートIPがすべてプロキシのIPになってしまう。

Pound のドキュメントを読んだらその解決策が書いてあった。

Request Logging
 As a general rule, Pound passes all headers as they arrive from the client
browser to the back-end server(s). There are two exceptions to this rule:
Pound may add information about the SSL client certificate (as described
below), and it will add an X-Forwarded-For header. The general format is
X-Forwarded-for: client-IP-address. The back-end server(s) may use this
extra information in order to create their log-files with the real client
address (otherwise all requests will appear to originate from Pound itself,
which is rather useless).

要は X-Forwarded-For というアクセス元の IP をログに記録すればよい

httpd.conf の以下の行を書き換える

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""
combined
CustomLog logs/access_log combined

Analog 側に変更のいらない方法

%h を

\"%{X-Forwarded-For}i\"

に置き換える

本当のアクセス元が記録されないという決定的な問題がある。リバースプロキシ経由でない場合や別のプロキシ経由だった場合にもどうなるかわからない。

その代わり Analog 側では変更がいらない。

ログ分析(Analog)側で対応する

こっちのほうがスマート。

httpd.conf の LogFormat の最後に

\"%{X-Forwarded-For}i\"

を追加する

analog.cfg の LOGFORMAT(APACHELOGFORMAT) に変更が必要

Esehttpdをインストール

http://ghost.math.sci.hokudai.ac.jp/esehttpd/

コンパイル・インストール

./configure
make
make install

起動/停止

/usr/local/sbin/esectl start
/usr/local/sbin/esectl stop

設定ファイルの以下の行を変更(/usr/local/lib/esehttpd/conf/esehttpd.conf)

Port                    8081
User                    httpd
Group                   httpd
最終更新時刻: 2011年06月09日
コメント(2) [コメントを投稿する]
_ いちえ (2003-12-03 16:12)

ちくしょう。tDiaryのアップグレードできんガヤ

_ hajime (2003-12-04 00:48)

何が原因なんでしょうね。tdiary1.5.6入れてdata/に200311と200311~入れてrootでmisc/convert2.rbしたら、200311が消えてdata/2003/には空の200311.tdcと200311.tdrが生成されましたよ。1.5.5ではruby1.8.0との相性でエラーが出たし。あかんガネ。