cloudflare nginx

From WebHostingNeeds.com
Jump to: navigation, search
mkdir /etc/nginx/vhosts/

Create file

vi /etc/nginx/vhosts/cloudflare.conf

Add

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;
real_ip_header     CF-Connecting-IP;

Now include this file in nginx.conf

vi /etc/nginx/nginx.conf

Find

http {

Add Below

      include /etc/nginx/vhosts/*.conf;


List of cloudflare IP's

https://www.cloudflare.com/ips

You may need to update IP list at times.



cloudflare

nginx