Today, as I sat down to throw some lunch down my throat, I saw #myFirstCar go by on Twitter. Naturally I made a jokey post about it on Facebook and on the train ride home it occurred to me I should probably expand because a lot of people might not understand the inherent dangers of playing such an innocuous seeming little game.
So, now we've got our fully formed ghetto CDN running, everything's caching properly, coming from the right host, etc, there's one little problem: We still have just a little bit moar faster we can add, thanks to our favourite CDN. I chose to go with Cloudfront because, so long as you stick to the scrub tier, it's free for a year and, really, I don't ever see it costing that much.
Now that we've got everything set up and our VPS is running a little better, it's time to throw in the last little bit of faster. See, right now, we're still on the hook for serving our content assets. Sure our server's on a good connection, but what could get these tubby beasts out there faster than serving them right out of S3? Exactly.
In tonight's episode, we're going to go over running our ghetto CDN setup using Apache for our dynamic content and Nginx for everything else. This is the setup I use in my live environments partly because all my VPSes have two IPs, partly because Nginx goes like the clappers when it comes to static files.
Now that we've figured out what buckets things belong in and how to serve them, we need to spend a little time teaching our favourite CMS how to take advantage of our new setup. This post is entirely Drupal-specific so if you haven't seen the light or aren't curious about how easy it makes things, you may want to skip ahead to the next in the series, setting up a hybrid Apache+Nginx environment.
Since my dev environment runs Apache and only has 1 public IP, I use it for the entire ghetto CDN setup. This post is going to go over how I set it up and deal with things like CORS and limiting what static and content can and can't do.
Sometimes, when you're on a roll, it's hard to stop. What started out as a simple experiment to get static and content assets being served properly out of a multi-site Drupal installation eventually turned in to this rambling and incoherent collection of things mostly because I spend about 2 hours a day on a train with nothing worthwhile to be doing.