Restore Original IP Address on IPS Community Suite 4
So if you run CloudFlare on your website and you've just freshly installed IPS4, you may see in your userlist that everone seems to have an IP from the same IP range. This is because cloudflare handles your traffic now and thus the REMOTE_ADDR header is from cloudflare's servers IP now.
There are a few methods to do this, some of which requires you to have server access. If you are unsure if you have any module installed, upload this php file cloudflare.rar to your server and navigate to it.
Method 1 - Application Level To restore the original IP address on application level, you can make IPS4 use X_FORWARDED_FOR.
To do this, go to your Admin CP > Security and press the "Security Settings" button and make sure Trust IP addresses provided by proxies? is enabled:
Method 2 - Server Level (cPanel/WHM) (EasyApache with mod_cloudflare) To use this method, you must have some sort of sense of what you're doing and you must have cPanel/WHM installed on your server and must have WHM root access.
Run the following command on SSH:
# wget https://raw.githubusercontent.com/cloudflare/mod_cloudflare/master/EasyApache/installer.sh
# bash installer.sh
Alternatively, you can run this instead:
# bash <(curl -s https://raw.githubusercontent.com/cloudflare/mod_cloudflare/master/EasyApache/installer.sh)
Now navigate to easyApache on whm:
Go through the steps, in the "Short Options List" there should be a Mod CloudFlare option now:
Method 3 - Server Level (Manually) (RedHat/CentOS/CloudLinux) (Apache with mod_cloudflare)
mod_cloudflare has a few software dependencies that need to be installed first:
# yum install libtool httpd-devel
Next, you should download the mod_cloudflare source to your server:
# wget https://www.cloudflare.com/static/misc/mod_cloudflare/mod_cloudflare.c
Finally, install the module. Depending on your system, the command to run might be apxs or apxs2. So, run one of the below two commands. If you get a "Command not found" when running one, try the other:
# apxs -a -i -c mod_cloudflare.c
# apxs2 -a -i -c mod_cloudflare.c
Method 3 - Server Level (Manually) (Debian/Ubuntu) (Apache with mod_cloudflare)
mod_cloudflare has a few software dependencies that need to be installed first:
# apt-get install libtool apache2-dev
Note: If you find that you are unable to install apache2-dev then you should install:
# apt-get install libtool apache2-threaded-dev
Next, you should download the mod_cloudflare source to your server:
# wget https://www.cloudflare.com/static/misc/mod_cloudflare/mod_cloudflare.c
Finally, install the module. Depending on your system, the command to run might be apxs or apxs2. So, run one of the below two commands. If you get a "Command not found" when running one, try the other:
# apxs -a -i -c mod_cloudflare.c
# apxs2 -a -i -c mod_cloudflare.c
Method 4 - Server Level (Manually) (NGiNX with http-realip-module) Nowadays, NGiNX should have this module built in by default, so the only thing you will have to do is add the following lines to your site's configuration:
#CloudFlare
set_real_ip_from 199.27.128.0/21;
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 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;
real_ip_header CF-Connecting-IP;
Once you saved the configuration, be sure to restart nginx for the changes to take effect:
sudo service nginx restart