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