How to install Mod_Rpaf on cPanel

Let’s start the week with a very easy tutorial with mod_rpaf.  Today you will learn what is mod_rpaf and how to install Mod_Rpaf on cPanel based servers.

Rpaf means reverse proxy add forward, and mod_rpaf is a module designed for backend Apache servers. It’s useful when you are running for example Varnish or Nginx as front end server, and you need to get the real IP of your backend requests.

If you don’t use mod_rpaf for your web server, you won’t be able to catch the real IP address of your visitors, this is bad for system and seo statistics.

install mod_rpaf on cpanel

The previous graphic  represents a common proxy diagram, where the first element are your visitors, who come from Internet. The second one is your proxy server (Varnish or Nginx), and the last one is your real Apache web server.

How can I install Mod_Rpaf on cPanel servers?

Two mod_rpaf options are available:

  1. The original devs of mod_rpaf: https://github.com/gnif/mod_rpaf
  2. And a fork, with better stuff than the original: https://github.com/y-ken/mod_rpaf

We will use the last one, the fork, to install mod_rpaf, as it works pretty well on cPanel servers and we never had any problem using it. Let’s begin.

Login to your box as root and download the rpaf module

cd /root
wget https://github.com/y-ken/mod_rpaf/archive/master.zip
unzip master.zip

Now let’s compile the module

cd mod_rpaf-master/
apxs -i -c -n mod_rpaf-2.0.so mod_rpaf-2.0.c

Finally, add the module to install Mod_rpaf on cPanel

LoadModule rpaf_module modules/mod_rpaf-2.0.so
<IfModule mod_rpaf-2.0.c>
RPAFenable On
RPAFsethostname On
RPAFproxy_ips 127.0.0.1 xx.xx.xx.xx
</IfModule>

Restart Apache to apply the changes:

service httpd restart

Conclusion

As you see, you can install mod_rpaf on cPanel in just a few minutes, the setup is pretty much easy, and after your mod_rpaf is installed you should be able to get your real visitor’s IP address without any problems.

Please let us know if you have any questions about mod_rpaf setup on cPanel.

About the Author: Martin Keler

4 Comments

  1. Hi,
    when trying to compile the module i’m getting these errors:
    ===========================================
    apxs -i -c -n mod_rpaf-2.0.so mod_rpaf-2.0.c
    /usr/local/apache/build/libtool –silent –mode=compile gcc -std=gnu99 -prefer-pic -m64 -fPIC -DPIC -DLINUX -D_REENTRANT -D_GNU_SOURCE -pthread -I/usr/local/apache/include -I/usr/local/apache/include -I/usr/local/apache/include -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:130: error: ‘conn_rec’ has no member named ‘remote_ip’
    mod_rpaf-2.0.c:131: error: ‘conn_rec’ has no member named ‘remote_addr’
    mod_rpaf-2.0.c:131: error: ‘conn_rec’ has no member named ‘remote_ip’
    mod_rpaf-2.0.c:132: error: ‘conn_rec’ has no member named ‘remote_addr’
    mod_rpaf-2.0.c: In function ‘change_remote_ip’:
    mod_rpaf-2.0.c:145: error: ‘conn_rec’ has no member named ‘remote_ip’
    mod_rpaf-2.0.c:164: error: ‘conn_rec’ has no member named ‘remote_ip’
    mod_rpaf-2.0.c:165: error: ‘conn_rec’ has no member named ‘remote_addr’
    mod_rpaf-2.0.c:168: error: ‘conn_rec’ has no member named ‘remote_ip’
    mod_rpaf-2.0.c:169: error: ‘conn_rec’ has no member named ‘remote_addr’
    mod_rpaf-2.0.c:169: error: ‘conn_rec’ has no member named ‘remote_ip’
    mod_rpaf-2.0.c:170: error: ‘conn_rec’ has no member named ‘remote_addr’
    apxs:Error: Command failed with rc=65536
    .
    ======================================
    could you help with it ?

    Thank you.

    1. I guess that happens when you try to compile it against Apache 2.4 versions.

      I’ll update the tutorial as soon as I can but in the mean time try to find out a patch for Apache 2.4

      1. Hello,

        If it is still an issue 🙂 just run:
        # sed -i ‘s/remote_addr/client_addr/’ mod_rpaf-2.0.c
        # sed -i ‘s/remote_ip/client_ip/’ mod_rpaf-2.0.c
        before apxs command.

Leave a Reply

Your email address will not be published. Required fields are marked *