# drop this into /etc/nginx/sites-enabled/ and tweak
# this nginx config reverse proxies to the 3 running thin instances
# started by the myapp.yml example

upstream thin {
   server   unix:/tmp/thin.0.sock;
   server   unix:/tmp/thin.1.sock;
   server   unix:/tmp/thin.2.sock;
}

server {
  listen 80;
  root /var/www/myapp/public/;
  access_log /var/www/myapp/log/nginx.access.log;
  error_log /var/www/myapp/log/nginx.error.log;

  location / {
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    if (-f $request_filename) {
      break;
    }

    if (!-f $request_filename) {
      proxy_pass http://thin;
      break;
    }
  }

  error_page 500 502 503 504 /500.html;
  error_page 404 403 /404.html;
}
