Fast introduction:
As we all know CloudFlare is a CDN which helps you protect your website from DDoS attacks, bots and so on. And it works like a proxy server, therefore the IP you can get from the requests isn't the one of the client, but the CDN's.

Before we start you need to know, that the commands below are for Debian, therefore if you're using another OS check for the alternative commands.
And also if you get some problems Google them!

Enough! Let's fix this one!
Firstly you need to install the Nginx and the http_realip_module

Follow the instruction below and read the comments:

#Run this, if you already have installed Nginx server before
#Note that it removes nginx, so you may like to keep some configuration you've done before!

apt-get remove nginx*

#Update the local cache of packages:
apt-get update

#Install nginx from Dotdeb Repository
apt-get install nginx -y

If you get any errors, google them.

Good Job! Now you will need to create a new file and paste some code in it, and include it to the nginx.conf

#Change the directory to /etc/nginx
cd /etc/nginx

#Create a file named cloudflare with the following contents
nano cloudflare

set_real_ip_from 173.245.48.0/20;
set_real_ip_from 103.21.244.0/22;
set_real_ip_from 103.22.200.0/22;
set_real_ip_from 103.31.4.0/22;
set_real_ip_from 141.101.64.0/18;
set_real_ip_from 108.162.192.0/18;
set_real_ip_from 190.93.240.0/20;
set_real_ip_from 188.114.96.0/20;
set_real_ip_from 197.234.240.0/22;
set_real_ip_from 198.41.128.0/17;
set_real_ip_from 162.158.0.0/15;
set_real_ip_from 104.16.0.0/12;
set_real_ip_from 172.64.0.0/13;
set_real_ip_from 131.0.72.0/22;
set_real_ip_from 2400:cb00::/32;
set_real_ip_from 2606:4700::/32;
set_real_ip_from 2803:f800::/32;
set_real_ip_from 2405:b500::/32;
set_real_ip_from 2405:8100::/32;
set_real_ip_from 2a06:98c0::/29;
set_real_ip_from 2c0f:f248::/32;

real_ip_header CF-Connecting-IP;
#Save it

#Now edit nginx.conf and include the cloudflare file after http {
nano nginx.conf

http {
include /etc/nginx/cloudflare;
#Save it

#Now you need to reload nginx with the new configuration
service nginx reload

Thats it!

Official Ip Ranges Of CloudFlare