How to accept only some IPs?

Hi, I’d like to accept only a few IPs and deny all the other requests.
e.g.: I accept only 88.49.29 and 39.42.43/20 and I deny all the other IPs.
I can’t do this server-side cause my server receives requests from cloudflare and can’t see what is the primary IP.

Firewall Rules is a much easier way to block by IP address:


As @sdayman suggested it is much easier to use Cloudflare (CF) firewall and connections never receive to your server. If you still want to block on your server you can find real client IP at CF-Connecting-IP header added by CF.