cloudflare

My blog is using CDN

Well, after reviewing some CDN products finally I choose Cloudflare. Actually I’ve use Cloudflare for matakanan project butbut I had to shut down cloudflare because I found incompatibility issue with javascript.

CDN also known as Content Distribution Networks provided more availability and can speed up my website on internet, and also for security enhanced because visitor doesn’t touch my server directly. First time running with Cloudflare I had a problem with nginx setup and I couldn’t get real IP visitors and only get IP addresses from Cloudflare network, but isn’t a big deal because I can use module realip on nginx to fix it. By using Cloudflare free CDN services I can get all benefits of CDN.

I’m too lazy to write in other article about how to get real IP visitor when using Cloudflare and nginx as web server so I wrote in here also. Firt things please make sure that your nginx has installed with http realip module you can ensure this module with the following command:

# nginx -V |grep realip

And then add the following IP addresses on nginx setup

204.93.240.0/24
204.93.177.0/24
199.27.128.0/21
173.245.48.0/20
103.22.200.0/22
141.101.64.0/18
108.162.192.0/18
190.93.240.0/20
188.114.96.0/20
198.41.128.0/17
2400:cb00::/32
2606:4700::/32
2803:f800::/32

Use the following setup for an example:

    server {
        listen      blog.pnyet.web.id:80;
        server_name  blog.pnyet.web.id;
        }

        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   190.93.240.0/20;
        set_real_ip_from   188.114.96.0/20;
        set_real_ip_from   198.41.128.0/17;
	set_real_ip_from   2400:cb00::/32;
	set_real_ip_from   2606:4700::/32;
	set_real_ip_from   2803:f800::/32;
        real_ip_header     CF-Connecting-IP;

I use CF-Connecting-IP because my server doesn’t run as reverse proxy.
HTH

Leave a Reply

Your email address will not be published. Required fields are marked *


*