Forum Discussion
Apache2.2 logging "Real" Client IP's - Mod_CloudFlare
Ok, we were able to resolve this issue with the following:
1) Logging real client IP's in apache logs:
Adding "%{X-Forwarded-For}i" to the LogFormat config in httpd.conf worked:
LogFormat "%{X-Forwarded-For}i - %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%{X-Forwarded-For}i - %h %l %u %t \"%r\" %>s %b" common
2) Passing the real client IP to php
I talked this over with a developer on staff and we were able to use php's auto_prepend_file to make this happen:
.htaccess file:
php_value auto_prepend_file proxy.php
proxy.php contents:
Note: We switched out $trusted_proxy with the floating IP address of the load balancer.
This works as expected.
Note that this is very much a workaround (think bandaids/ducktape) until the code can be updated or a more robust solution can be found. I, for one, am hoping for a mod_f5 🙂
This link provided the inspiration for that code: https://devcentral.f5.com/questions/apache22-logging-quotreal-quot-client-ips-mod_cloudflare
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
