Need to show real, original visitor IP addresses in a Joomla website with Cloudflare, instead of the proxy? There's an easy way, no coding or plugins...
Although I absolutely love Cloudflare for their caching, SSL, and DDoS protections features, their proxy can be both a blessing and a curse.
The Problem: No Actual Visitor IP Address
The core issue revolves around the fact that Cloudflare masks real user IPs with their own via their proxy. This means that all of your visitors end up showing that they came from a handful of IP addresses, which is obviously not real.
This is especially a problem in regards to security, and the ability for tracking, logging and banning of IP addresses when needed.
The Old Solution: Cloudflare For Joomla 3.X Plugin
In Joomla version 3.x (and prior), there was a fantastic plugin called "Cloudflare for Joomla" (cf-joomla.zip). All that was required was to install and activate the extension. However, this unfortunately stopped working starting with Joomla 4.X and ever since then a lot of people have been trying to find a solution to this issue.
The New, Easy Solution: Enable "Behind Load Balancer" Setting
Over the last year, I spent well over 10 hours searching online for a solution to this issue, and I finally found it... Simply enable the "Behind Load Balancer" setting in your Joomla Global Configuration.
That's it. That's seriously all it takes, pending your server is configured properly otherwise.
Check the "Behind Load Balancer" box in: Global Configuration < Server < Proxy
Summary: Hoping To Help Others Find The Solution
I feel pretty dumb that it took me so long to realize the solution, but that's exactly why I am writing this article. In all my searching, nobody ever specifically mentioned that the "Behind Load Balancer" setting actually resolves this exact issue when using both Cloudflare and Joomla.
I hope that this information can help others in a much faster fashion than it took me.