Real IP logging with NPM and Apache

Last update May 12, 2023

NPM (Ngnix Proxy Manager) comes already with the required config to pass the real client IP to the webserver behind the reverse proxy. If you use Apache, all you need is setting the remoteip module as follows:

# a2enmod remoteip
# vim /etc/apache2/conf-available/remoteip.conf

and add:

<IfModule mod_remoteip.c>
    RemoteIPHeader X-Forwarded-For
    RemoteIPTrustedProxy <NPM_IP_ADDRESS>
</IfModule>

then activate your conf and restart the service:

# a2enconf remoteip
# service apache2 restart