Source:
https://www.globo.tech/learning-center/x-forwarded-for-ip-apache-web-server/
http://httpd.apache.org/docs/2.4/mod/mod_remoteip.html#remoteiptrustedproxy
Logs from wordpress log source ip address of nginx proxy server not real address
wordpress_1 | 192.168.96.2 - - [15/Oct/2019:14:25:16 +0000] "GET / HTTP/1.1" 200 25316 "-" "Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.1 Mobile/15E148 Safari/604.1"
- modify “/etc/apache2/apache2.conf”
LogFormat "%a %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
- to
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
- add 2 lines to apache2.conf
RemoteIPHeader X-Forwarded-For RemoteIPTrustedProxy 192.168.96.2
- link
remoteip_module toapache mods-enabled
cd /etc/apache2/mods-enabled/ ln -s ../mods-available/remoteip.load
- restart apache2 service and apache logs real IP adresses
wordpress_1 | 194.154.249.108 - - [15/Oct/2019:14:28:56 +0000] "GET / HTTP/1.1" 200 25316 "-" "Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.1 Mobile/15E148 Safari/604.1"