Brian’s Code Blog

Using ngnix with Unicorn

So there's a new kid on the block in the ruby server world, Unicorn. The guys over at github have a good writeup on their blog about what it is and how to user it, that also posted a god config file to monitor it. Also if you want a good explanation of why unicorn is cool, check out Ryan Tomayko's article "I like Unicorn because it's Unix". One important note on both their unicorn config and their config, the paths they have are very specific to their setup. If you're running a normal capistrano setup, you'll want to store the sockets and pids in the shared directory rather than the current. So now the only part is the front end web server. This typically tends to be nginx(pronounced engine x) or apache these days, though litespeed and lighttpd are good as well. My personal choice is nginx, installing it and getting running is pretty easier and straight forward. All that's left to do is tweak the nginx.conf file. I used a modified version of ezra's nginx.conf file. Here's the conf with my optimizations:

Note if you're not using a socket just set the server in the upstream block to 127.0.0.1:<%=@port %>

Filed under  //   nginx   ruby   unicorn