xyzio

Aliasing a sub-domain to Amazon s3 at WinHost

leave a comment »

One of the major problems with WinHost is that you don’t get much disk space, their base plan comes with not even 2GB but 2000MB.  One way to stretch this disk space is to host images and other big files using Amazon’s S3 service and just keeping your ASP.NET/PHP e.t.c code files at WinHost.  To make this hosting appear seamless to your visitors, Amazon allows users to alias a sub-domain or domain to their hosting service.  This way users see your domain i.e s3.xyzio.com but the files are pulled from AWS.

The setup is not very complicated and takes about 2 hours, most of which is spent waiting for your sub-domain name to propagate.  First, log into the AWS S3 console and create a bucket named after your sub-domain – s3.xyzio.com here:

Create Bucket in Amazon S3 AWS

Then log into your WinHost control panel and click on DNS Manager.  There under Manage CNAME Records enter your sub-domain for Domain Name,  s3.amazonaws.com for the Destination and 3600 for TTL.  TTL stands for Time-To-Live and denotes how long in seconds the alias is maintained before it is refreshed.  Here setting it to 3600 means that it will be refreshed every hour:

WinHost CNAME Record Setup

Now wait for about two hours.  Then you can access any file you’ve uploaded on AWS using the following format: http://<domain>/<directories>/<file-name>.  For example, the image above is hosted on AWS at the following address: http://s3.xyzio.com/s3_cname/winhost_cname.jpg.

You can use https to securely link to your image.  This will throw a warning message in your browser because the domain and hosted domain names are different i.e. https://s3.xyzio.com/s3_cname/winhost_cname.jpg.

Of course you can also link directly to your file using the AWS linking convention: https://s3.amazonaws.com/s3.xyzio.com/s3_cname/winhost_cname.jpg or http://s3.xyzio.com.s3.amazonaws.com/s3_cname/winhost_cname.jpg

And that is it.  Now you can easily extend your disk space at WinHost without having to upgrade!

Advertisements

Written by M Kapoor

June 27, 2013 at 7:17 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: