KISS High Availability
Let me be straight with you. I hate most tools. Software developers tend to write tools for themselves, which makes sense. But then, they just publish the highly customized thing they use. Often times, because they're software developers, there are unaccounted for dependencies, a mess of custom directories, and even arbitrary naming conventions.
What is High Availability?
When should we HA something?
Cut to the chase. How do we do it?
rsync keeps the servers in sync
rsync -av /etc/nginx/ <user>@<server ip>:/etc/nginx
You can find more about rsync here.
cron does the automation
Of these 3, cron's role is simple. It runs rsync regularly. That's it. In my case, nightly is enough. I don't add new websites behind my reverse proxy all that often, so nightly is enough to keep things up to date. Here's my crontab for the above script to run nightly:
keepalived handles failover
keepalived is a simple tool to create a pool of servers that take over for each other, should one fail. Well, it doesn't create the pool. It adds the server to the pool. So you run keepalived on each server you want to be part of that pool, using the same configuration (that helps identify the pool) and they do just that. Setting up keepalived just requires a configuration file /etc/keepalived/keepalived.conf which looks something like this:
Have we missed anything? Well, we could go beyond, moving the server off-site. We could certainly look at syncing other directories (but this works for now). I think we're doing pretty well. I will be improving my scripts in the coming days, but this is all working and didn't require 30 hours of mastering tool configurations. I'm pretty happy with it.