When using a reverse proxy (such as is outlined here), logs such as
/var/log/apache2/other_vhosts_access.log will likely show the ip address of the proxy (not the client's ip address).
We can use remoteip and X-Forwarded-For to pass the clients ip address for logging purposes. This requires a few changes to the apache2.conf file.
You'll need to implement the following using either the a2enconf method or put it in each individual vhosts directive for specific sites.
Suggested method: a2enconf
This method is the suggested method since we can keep our vhost directives clean and implement the X-Forward-For as default.
Create a apache2 conf file (we'll call it remoteip.conf)
Save and exit, and then enable the
remoteip mod this conf by
Alternative method: vhosts method
I'm assuming your apache2 <proxy>.conf file is of the form discussed in Apache reverse-proxy SSL to multiple server applications. You'll need to add RemoteIPHeader and RemoteIPTrustedProxy to each on the<VirtualHost *:443> code blocks. For example:
Regardless of which of the method above you use, you'll now need to make a quick change to the /etc/apache2/apache2.conf file.
Search for the
LogFormat arugments, you'll basically need to replace the
%h instances with
%a. It should look something like this when you're done:
Finally, reload the apache2 configuration files (or restart apache2) with: