[HOW-TO] Install mod_rpaf for Apache 2.2

By BXTra |

When you do a reverse proxy in which Nginx will be the one who listen the traffic and forward anything needs to be process through PHP to Apache. With this, Apache will always receive an IP from Nginx server (or I should say localhost / / local IP), not the real IP that user uses. In order to let Apache knows what is real user IP, we need to install mod_rpaf.

Just copy and paste code below into SSH :

wget http://stderr.net/apache/rpaf/download/mod_rpaf-0.6.tar.gz
tar xvfz mod_rpaf-0.6.tar.gz
cd mod_rpaf-0.6
sed -ie 's/apxs2/apxs/' Makefile
make rpaf-2.0
make install-2.0

After compiled, do some configuration as below :

LoadModule rpaf_module /usr/lib/apache/mod_rpaf-2.0.so

<IfModule mod_rpaf.c>
RPAFenable On
RPAFsethostname On
RPAFheader X-Forwarded-For

RPAFproxy_ips can be multiple IP address and it's IP from your reverse proxy.

RPAFproxy_ips xxx.xxx.xxx.xxx


Update (2011.02.15) :

If, for some reason, you tried it and it didn't work. Try to recompile and restart Apache again. After I setup above configuration, it worked fine for a day until I found that it no longer worked. I didn't say it will stop working by itself. I believe it went bad because I did restart Apache service very often after set this up. ( To test Nginx :P )

Test Configuration :
1. CentOS 5.4 / 5.5 - 64 bits
2. DirectAdmin 1.37 - With Custombuild 1.2
3. Apache 2.2.17
4. mod_rpaf 0.6

Source :
- http://maxgarrick.com/reverse-proxy-with-nginx/
- http://stderr.net/apache/rpaf/

Hello, I follow your guide installation fine. apache can start fine. but after I view "server-status" page from "mod_status" I found all client ip is serverip. How to solve this problem ? (I applied your tutorial nginx proxy) Regards, Metee


12 years 4 months ago

Sometimes, the apxs binary is not known and its full path is required.
cd /usr/local/src
sudo wget -O    mod_rpaf-$APACHE_MOD_RPAF_VERSION.tar.gz "http://stderr.net/apache/rpaf/download/mod_rpaf-$APACHE_MOD_RPAF_VERSION.tar.gz"
sudo tar  -xvzf mod_rpaf-$APACHE_MOD_RPAF_VERSION.tar.gz
sudo rm   -rf   mod_rpaf-$APACHE_MOD_RPAF_VERSION.tar.gz
cd              mod_rpaf-$APACHE_MOD_RPAF_VERSION

# Fix Makefile
sudo sed -ie 's/\$(APXS)/\/usr\/local\/apache\/bin\/apxs/' Makefile
sudo sed -ie 's/\$(APXS2)/\/usr\/local\/apache\/bin\/apxs/' Makefile

sudo make rpaf-2.0 && sudo make install-2.0 && cd /usr/local/src
sudo rm   -rf   mod_rpaf-$APACHE_MOD_RPAF_VERSION

Add new comment

  • No HTML tags allowed.
  • Web page addresses and email addresses turn into links automatically.
  • Lines and paragraphs break automatically.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.