linux中apache 2.4 安裝 mod_rpaf教程

來源:互聯網
上載者:User

在使用第三方的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

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.