Page 1 of 1

Replacing rpaf module with remoteip

Posted: Fri Nov 02, 2018 8:36 am
by plutocrat
I've had a small niggling problem for a few months, but haven't got around to fixing it until now. In the default apache+nginx installation for Ubuntu, the module libapache2-mod-rpaf is installed. This works OK up to a point: it logs the correct remote IP in the server logs in /var/log/apache2/domains/. However the apache traffic report at https://your.server.address:8083/list/server/?web shows the incorrect IP address: that of the server itself.
[If you can't find this, its
Dashboard > Server > SHOW CPU/NET/MEM/DISK > Web
I used VestaCP for around a year before I discovered this section! ]

So it seems the way to fix this is to replace rpaf with remoteip. Here are the steps:
nano /etc/apache2/mods-available/remoteip.conf

and add these lines replacing the IP address with the IP address of your server.

Code: Select all

<IfModule remoteip_module>
    RemoteIPHeader X-Forwarded-For
    RemoteIPInternalProxy 22.33.44.55 
</IfModule>
Now swap the modules over, but don't restart apache yet.

Code: Select all

a2dismod rpaf
a2enmod remoteip
Now open up /etc/apache2/apache2.conf and alter the Logfile format. Find these lines

Code: Select all

LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
and change the %h at the beginning of each one to %a

Code: Select all

LogFormat "%a %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%a %l %u %t \"%r\" %>s %O" common
Test:

Code: Select all

apachectl -t
Restart apache

Code: Select all

systemctl restart apache2.service
Check the logfiles to make sure the correct IP addresses are appearing. And then check the apache status page.
https://your.server.address:8083/list/server/?web