nginx logo The nginx build in the official ubuntu package repository is somewhat out-of-date, so I built my own package from source using 0.7.59. I’m going to provide it here in case anyone else would like it. One of the new features I like is the try_files directive. Here’s an example of what I’m doing using 0.6.35, the full post is here http://lithostech.com/lighten-apaches-load-nginx:

location / {
  root /var/www/fresnobeehive.com;
  proxy_set_header X-Forwarded-For  $remote_addr;
  if (-f $document_root/beehive$uri) {
    rewrite (.*) /beehive$1 break;
  }
  if (-f $request_filename) {
    break;
  }
  if (-f $request_filename/index.html) {
    rewrite (.*) $1/index.html break;
  }
  if (-f $document_root/beehive$uri/index.html) {
    rewrite (.*) /beehive$1/index.html break;
  }
  if (!-f $request_filename) {
    proxy_pass http://fresnobeehive.com:8080;
    break;
  }
}

Continue reading »

nginx logo Since we’ve been on slicehost, I’ve been forced to play the role of system administrator since we don’t have a real one. One problem I’ve run into is the long string of legacy applications that I have to support. Some of them I wrote, and some of them I inherited. For many reasons, they’re often organized and run in sub-optimal ways. Separating your static and dynamic content is a good habit to get into when you’re building scalable web applications. Static content is highly portable because it can live without context. You can serve it from anywhere and nobody knows the difference. When your site starts to get huge traffic, you can easily offload your static content to a CDN if you host it in an easy-to-separate way using an URL like static.domain.com or domain.com/static.

Continue reading »