Web Design

VPS: It's Awesome, and It Might Kill Me

So, I made the leap from shared hosting to a virtual private server.  Why?  A few reasons:

  1. You'll never get great performance from shared hosting
  2. I've gained confidence in my own ability to devops
  3. I'm trying to improve my skill set
  4. It's actually cheaper; $7/mo for Hostgator shared hosting vs. $5/mo for Digital Ocean
  5. It's fun!  (I need to get out more.)

My first reaction?

Not even kidding.  It was literally as fun as flying an alien spaceship out of a secret government facility with Jeff Goldblum.  Why?

Simply put: I can do cool stuff now.  Varnish.  Memcached.  New Relic.  Control my own environment, including resources and firewall.  If I want I can double my resources for $10/mo, but I won't need to.  I'm hosting 8 websites off a single server, and every single one of them screams.  Here's a quote from an actual client:

IT’S FANTASTIC! You’re right; much, much faster.  In fact, instant!!!!!    THANK YOU!

Of course, it's got its challenges.  The biggest was mail.  I had lots of mail forwarders set up, and several domains use Google Apps.  Now I need to figure out how to manage all those myself.
The answer: postfix.  Well, there are multiple answers, of course, but postfix seems to be popular for being simple.  Of course it's not really that simple.  First you have to set up the postfix daemon itself, with text-only configuration files.  Then you have to set up an authentication engine.  I chose dovecot because it had the clearest "howto."  Plus several hours of banging my head against a wall.  Literally.  (Turns out the banging didn't help.)
So, how to do it?  Here's how:

How to Set Up Mail Forwarding on a VPS

First, what this isn't: This isn't a full-fledged mail server.  No POP3, no IMAP.  No local storage of emails.  No spam filtering, no antivirus.  All my forwards are going to gmail, which already has excellent spam filtering and antivirus.  Maybe one day when I'm bored I'll add these things, but honestly at this point I'm afraid to sneeze at the server.  This feeling will pass.  Give me 24 hours and I'm sure I'll be messing with it in ways that would make Marilyn Manson say "dude, tone it down."

This is a mail forwarder.  It's also an SMTP server; I can send emails from my virtual domains, eg. me@mydomain.com.  The trick is making sure the spammers don't get in; I made that mistake back in 2003, when I was running an IIS server out of my apartment.  Good times.

OK, so how did I stumble into success?

Install Postfix

Read this excellent tutorial from Digital Ocean.  Turns out Digital Ocean is really cool like that.  They don't just hand you the keys to the porsche (although they do that); they also hand you a map and driving directions to the nearest gas station and the freeway.  In this case, they had a tutorial for the specific operating system I was using.

Short version: install the daemon using apt-get.  Edit the text-only configuration file.  Restart the daemon.

Add virtual aliases

Turns out it doesn't matter if you've already edited your MX records to point to Google Apps.  The mail request still goes through postfix first.  So you need a "virtual" file where you list your aliases.  Eg. special@mydomain.com forwards to regular@gmail.com.

Tip: You have to load your "virtual" file into postfix after you edit, and then restart the postfix daemon again.

Add Dovecot

You have to add an authentication engine.  No, really.  There's a sasl_passwd file, but that's not enough.  You have linux accounts, but that's not enough either.  You need a separate engine to handle the actual smtp sasl authentication.  Starting to sound like gibberish?  That's ok, I don't really know what any of this means, I just know that when I followed a few tutorials and banged at it for a few hours, it ended up working.

Anyway, yeah.  You need Dovecot.


It wasn't really that bad.  If i had to do it again, I could do it pretty quickly and easily using these tutorials:




The painful part was the trial and error, setting up something I knew nothing about, and which was a dubious idea in the first place.  But it worked, and I'm going to bed.

clever girl