Nếu dùng nginx edit file nginx.conf ở section http như sau
http { set_real_ip_from 204.93.240.0/24; set_real_ip_from 204.93.177.0/24; set_real_ip_from 199.27.128.0/21; set_real_ip_from 173.245.48.0/20; set_real_ip_from 103.22.200.0/22; set_real_ip_from 141.101.64.0/18; set_real_ip_from 108.162.192.0/18; real_ip_header CF-Connecting-IP;
Nếu dùng Varnish trước nghinx thì sửa như vậy và add trên ip 127.0.0.1 vào danh sách như trên
http { set_real_ip_from 204.93.240.0/24; set_real_ip_from 204.93.177.0/24; set_real_ip_from 199.27.128.0/21; set_real_ip_from 173.245.48.0/20; set_real_ip_from 103.22.200.0/22; set_real_ip_from 141.101.64.0/18; set_real_ip_from 108.162.192.0/18; set_real_ip_from 127.0.0.1/32; real_ip_header CF-Connecting-IP;
Câu hỏi là mấy ip trên lấy ở đâu.Dễ lắm vào http://cloudflare.com/ips có gần đủ ip của cloudflare đó.Tất nhiên là ko đủ vì mình đã kiểm tra