How to use CoralCDN to help reduce bandwidth usage / server resources

If you have noticed since several weeks ago (if i recall it correctly because i completely forgot since when i enabled this although it’s not really that far lol) when you visited this domain name, sometimes you’ll see request appended on (like and if you’re wondering on why there are several request made to that domain? then here in this post i’m going to explain it

So basically is a domain name used by CoralCDN (a free Content Delivery Network) that allows you (as a website owner) to utilize their CDN Service to serve your content directly from their servers. And in most case, usually CoralCDN is used by many site owners when their website that is hosted on small server / shared hosting got linked from many popular website such as Digg, Slashdot, Reddit, etc. to help them survive the effect (Check this wikipedia page for more info) … although it can be used for any other purpose as well … like for example if you host your site from your own computer that doesn’t have enough bandwidth to supply all your site visitors, or just simply want to reduce the load on your server, or perhaps just to save bandwidth :D

And so without further ado, here’s on how to use CoralCDN as your personal site saver :)

Note: This is tested on Apache Web Server 2.2, and also make sure to enable mod_rewrite and mod_headers before continuing with this process

As for on how to enable mod_headers and mod_rewrite, just open your httpd.conf that is located in your Apache installation directory and locate this lines:

#LoadModule headers_module modules/
#LoadModule rewrite_module modules/

And remove the # character to enable them so it’ll looks like this

LoadModule headers_module modules/
LoadModule rewrite_module modules/

But of course if you choose to not build Apache modules as shared / DSO modules that can be toggled (static modules compile), then you’ll need to compile the modules first

Anyway, let’s begin the process

Using CoralCDN to serve your static files such as images, javascript, etc

1. Let’s say you put your image files inside images directory, and so every request to your image files will look like
2. Now you need to locate .htaccess file on your document root
3. Insert these lines into your .htaccess file to redirect all the requests made to that images directory to be served by CoralCDN and if you have reached your limit on CoralCDN, all the request will be reverted back to your site/server:

Header append X-Coral-Control "redirect-home"
RewriteCond %{HTTP_USER_AGENT} !^CoralWebPrx
RewriteCond %{QUERY_STRING} !(^|&)coral-no-serve$
RewriteRule ^images/(.*)$$1 [R,L]

Alternatively, if you prefer to make all requests made by your self to not get redirected to CoralCDN (so that mean all of your site visitors will be served by CoralCDN but not you), you can use these instead:

Header append X-Coral-Control "redirect-home"
RewriteCond %{HTTP_USER_AGENT} !^CoralWebPrx
RewriteCond %{REMOTE_ADDR} !^123\.456\.789\.0
RewriteCond %{QUERY_STRING} !(^|&)coral-no-serve$
RewriteRule ^images/(.*)$$1 [R,L]

And replace


with your IP Address

That’s it … and you’re done … now you can save your server resources and bandwidth by offloading all static images to CoralCDN, unless of course you want to completely offload your site to CoralCDN, which is described below

Using CoralCDN to serve all requests made to your site

1. Locate the Document Root of your site
2. Create (or edit) .htaccess file on your document root
3. Insert these lines

Header append X-Coral-Control "redirect-home"
RewriteCond %{HTTP_USER_AGENT} !^CoralWebPrx
RewriteCond %{QUERY_STRING} !(^|&)coral-no-serve$
RewriteRule ^(.*)$$1 [R,L]

And just like before if you want to exclude your self from being redirected to CoralCDN you can always add

RewriteCond %{REMOTE_ADDR} !^123\.456\.789\.0


RewriteCond %{QUERY_STRING} !(^|&)coral-no-serve$

But what if you get 500 Internal Server Error message after placing the above code? that means you haven’t enabled mod_headers and or mod_rewrite yet, or you mistype something … somewhere

p.s. Although it’s possible to use Conditional Check to make sure that even if you forget to enable mod_rewrite and mod_headers to not throw error message, but for this purpose i think it’s better not to use conditional check so you’ll know whether the redirection to CoralCDN is working or not … and if it’s not working because mod_headers and mod_rewrite not enabled, you’ll get a beautiful 500 Internal Server Error Message

p.p.s Be warned, there is a limit on CoralCDN (i’m not sure on how big/small the limits are) so whenever you’ve reached your limit you’ll get the amazing 403 Forbidden Error, but with the mod_headers placed when Coral return 403 error, all the requests will be reverted back to your site


Note: Comment may not appear right away.

9 comments on “How to use CoralCDN to help reduce bandwidth usage / server resources

  1. sir, i installed the htaccess on a subdomain, with modification to the code

    Header append X-Coral-Control “redirect-home”
    RewriteCond %{HTTP_USER_AGENT} !^CoralWebPrx
    RewriteCond %{QUERY_STRING} !(^|&)coral-no-serve$
    RewriteRule ^(.*)$$1 [R,L]

    i tried to access now it showed up but i cant confirm if its already from coralcdn or still a normal link.

    any help to verify?

  2. Pay attention when you copy/paste the code from this website; there are no tabs on the code, so, you’ll get a 500 error even if you have mod_headers and mod_rewrite not enabled. Please correct this (ex.: “redirect-home”RewriteCond, you must put a tab between ” and RewriteCond).


    1. I’m sorry about that one, because well previously i use code tag with br tag (on all posts that needs it) and recently (probably several weeks ago) i changed all the code tag (automatically) to pre tag and that results in the br tag not being displayed as new line

      Thanks for the report, fixed :)

    1. You’re very welcome Mark and i’m really sorry for late reply because i just recently moved to another city :)