Show Real Visitor IP Instead of CloudFlare IPs

How Can We Help?
< Back
You are here:

When using CloudFlare CDN in front of your OpenLiteSpeed Web Server, you may see a proxy IP instead of the real IP addresses of visitors.

To restore real visitor IPs, navigate to OpenLiteSpeed WebAdmin Console > Server Configuration > General Settings. Set Use Client IP in Header to Trusted IP Only. Add CloudFlare IPs/Subnets to the trusted list, as shown below.

It is not recommended to set Use Client IP in Header to Yes, because it allows clients to spoof IPs with the X-Forwarded-For header that is sent to CloudFlare.

Add the list of CloudFlare IP subnets, available on CloudFlare’s website, to OpenLiteSpeed’s Access Control > Allowed List in a comma-separated list, appending a T (for “Trusted”) to the end of each IP, like so:


This is how it should look:

If you have another layer of proxy set up in front of OpenLiteSpeed Web Server on the same server box (i.e. CloudFlare Railgun, nginx, or Varnish), you will also need to add that server IP to the trusted list.

Once enabled, your access logs will show the correct IP addresses and even PHP’s $_SERVER['REMOTE_ADDR'] variable will contain your visitors’ real IP addresses instead of a CloudFlare IP address. This will resolve most problems that might occur when enabling CloudFlare on PHP-enabled web sites (like WordPress or vBulletin installations).

Please be aware that only the access log shows real visitor IPs. The error log still shows the IPs of CloudFlare nodes. This may change in a future release.