在使用第三方的DANginx外掛程式用在Directadmin apache2.4的時候,發現無法安裝mod_rpaf.這個外掛程式是用來讓apache擷取到訪客正確ip的。
apache2.4已經有了mod_remoteip.so 但沒時間仔細研究,Directadmin無法正常載入,先行編譯mod_rpaf達到要求
編譯時間提示的錯誤
# apxs -i -c -n mod_rpaf-2.0.so mod_rpaf-2.0.c
/var/www/build/libtool --silent --mode=compile gcc -std=gnu99 -prefer-pic -DLINUX -D_REENTRANT -D_GNU_SOURCE -g -O2 -pthread -I/usr/include/apache -I/usr/include/apache -I/usr/include/apache -c -o mod_rpaf-2.0.lo mod_rpaf-2.0.c && touch mod_rpaf-2.0.slo
mod_rpaf-2.0.c: In function 'rpaf_cleanup':
mod_rpaf-2.0.c:150: error: 'conn_rec' has no member named 'remote_ip'
mod_rpaf-2.0.c:151: error: 'conn_rec' has no member named 'remote_addr'
mod_rpaf-2.0.c:151: warning: implicit declaration of function 'inet_addr'
mod_rpaf-2.0.c:151: error: 'conn_rec' has no member named 'remote_ip'
mod_rpaf-2.0.c: In function 'change_remote_ip':
mod_rpaf-2.0.c:164: error: 'conn_rec' has no member named 'remote_ip'
mod_rpaf-2.0.c:183: error: 'conn_rec' has no member named 'remote_ip'
mod_rpaf-2.0.c:186: error: 'conn_rec' has no member named 'remote_ip'
mod_rpaf-2.0.c:187: error: 'conn_rec' has no member named 'remote_addr'
mod_rpaf-2.0.c:187: error: 'conn_rec' has no member named 'remote_ip'
apxs:Error: Command failed with rc=65536
解決辦法:
wget http://soft.dahualab.com/manage/directadmin/easyinstall/mod_rpaf-0.6.tar.gz
tar xzvf mod_rpaf-0.6.tar.gz
cd mod_rpaf-0.6
apxs -i -c -n mod_rpaf-2.0.so mod_rpaf-2.0.c
mod_rpaf讓apache擷取訪客真實IP
安裝好了之後,需要對httpd.conf檔案進行配置。
1、在httpd.conf加入如下代碼:
1.<IfModule mod_rpaf.c>
2.RPAFenable On
3.RPAFsethostname On
4.RPAFproxy_ips 127.0.0.1
5.RPAFheader X-Forwarded-For
6.</IfModule>
載入模組代碼:
1.LoadModule rpaf_module modules/mod_rpaf-2.0.so
2、並定義日誌格式
1.LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" varnishcombined
3、以後可以使用如下代碼啟用此格式的日誌:
1.CustomLog "/home/wwwlogs/$domain.log" varnishcombined