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 .nyud.net request appended on reaper-x.com (like images.reaper-x.com.nyud.net) and if you’re wondering on why there are several request made to that nyud.net domain? then here in this post i’m going to explain it

So basically .nyud.net 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/mod_headers.so
#LoadModule rewrite_module modules/mod_rewrite.so

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

LoadModule headers_module modules/mod_headers.so
LoadModule rewrite_module modules/mod_rewrite.so

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 http://www.example.com/images/blabla.jpg
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/(.*)$ http://www.example.com.nyud.net/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/(.*)$ http://www.example.com.nyud.net/images/$1 [R,L]

And replace

!^123\.456\.789\.0

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 ^(.*)$ http://www.example.com.nyud.net/$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

Before

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

Leave a comment

Comments

  1. Nation Channel tweetthenation.com/ Jul 8, 2014 at 8:12 PM

    Hey just wanted to give you a quic heads up and let you know a feww of thee images aren’t loading correctly.
    I’m noot sure why bbut I think its a linking issue.

    I’ve triied itt in two different browsers and both show thee same results.

  2. Cathy guidehorse.com/csp/uprofile.php?UID=183993 Jul 4, 2014 at 10:41 PM

    wonderful submit, very informative. I’m wondering why the other experts of this sector do not notice this.
    You should proceed your writing. I am confident, you have a huge readers’ base already!

  3. Titanfall gratuit titanfallgratuit.fr/ Jul 2, 2014 at 12:53 AM

    Pretty section of content. I just stumbled upon your site and in accession capital to assert that I
    get in fact enjoyed account your blog posts. Any way
    I’ll be subscribing to your augment and even I achievement you
    access consistently rapidly.

  4. hair building fibers https://studentsphere.zendesk.com/entries/44754000-Traditional-Cancer-Treatment-A-Regarding-Top-Control-Of-Cancer Jun 16, 2014 at 12:21 AM

    You can definitely see your expertise in the article you write.
    The sector hopes for even more passionate writers such as you who aren’t afraid to mention how they believe.
    Always follow your heart.

  5. Adam Rogacki Europarlament tafrihcity.ir/member.php?u=5-UKSL May 20, 2014 at 10:33 PM

    The more you love and apply loving solutions in all your
    life, the more you see loving results replacing earlier struggles or legal battles and dirty divorces.

    Office politics can sometimes override your chance of being hired.

    This seems at odds with the principle of equal voice at the polls.

    My site :: Adam Rogacki Europarlament

Comments Navigation 12

Trackbacks/Pingbacks

  1. Gratis cdn service coral via subdomain til .nyud.net « we-post-tech
  2. How to optimize and speed up Wordpress - Reaper-X

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>