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:
ALL, 22.214.171.124/22T, 126.96.36.199/22T, 188.8.131.52/22T, 184.108.40.206/12T, 220.127.116.11/18T, 18.104.22.168/22T, 22.214.171.124/18T, 126.96.36.199/15T, 188.8.131.52/13T, 184.108.40.206/20T, 220.127.116.11/20T, 18.104.22.168/20T, 22.214.171.124/22T, 126.96.36.199/17T, 188.8.131.52/21T
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.