Hosting a website for $0.10 a month
Recently I registered the domain “derp.army” and wanted to host a couple static pages on it, on the quick and cheap. Of course I have a server that works perfectly well, but the less complicated the infrastructure (or the less I have to run), the less headaches for me. The best solution for static websites I know of is AWS S3. Since this is obviously going to be an extremely popular website, we can’t forget to add a CDN in front of it, for that I chose Cloudflare. Here’s how I did it in a few easy steps.
- Go to S3
- Create a new bucket, name it whatever makes sense to you (it’s internal only)
- In the bucket properties, “Enable website hosting”
- Save the endpoint name, you’ll need it later
- Upload some files to your new S3 bucket, make sure they are marked as public
- Goto your Cloudflare account and add a new website
- Your first (and possibly only DNS record): Type = CNAME, Name = @, Value = <Your S3 Endpoint name> (Note: You’re right, technically you can’t set the Zone Apex to a CNAME, fortunately Cloudflare has you covered with CNAME flattening)
- Make sure the record is set active
- In the Cloudflare settings for the domain, make sure you set SSL to “Flexible SSL”
- Goto your domain name registrar and set your name servers to those that Cloudflare gives you
Wait a length of time and if all goes well, you should be able to check out your new website! If you have the Cloudflare Chrome plugin, it should light up in a lovely orange. If you’re using a free account (to hit that $0.10 price point), it’ll take 24 hours before Cloudflare turns your SSL on. However after that you can force SSL (using page rules). Cloudflare SSL also gives you the bonus of SPDY.
So how did I get $0.10 a month? S3 pricing will cost you in pennies a month for a small site. You do need to pay for per GB for storage, per 10,000 requests to your site, and data transfer out per GB. However, if you have a small site (which we’re assuming) and cache aggressively on Cloudflare, there shouldn’t be much transfer or requests. In fact, if you were tricky, you could use the AWS Free Tier to reduce that price to nothing for the first year!