# Config file based on sinatra's.

# you generally only need one nginx worker unless you're serving
# large amounts of static files which require blocking disk reads
worker_processes 8;

# # drop privileges, root is needed on most systems for binding to port 80
# # (or anything < 1024).  Capability-based security may be available for
# # your system and worth checking out so you won't need to be root to
# # start nginx to bind on 80
# user nobody nogroup; # for systems with a "nogroup"
#user nobody nobody; # for systems with "nobody" as a group instead

# Feel free to change all paths to suite your needs here, of course
# pid /tmp/nginx.pid;
#error_log /tmp/nginx.error.log;
error_log stderr error;

events {
  worker_connections 4096; # increase if you have lots of clients
  accept_mutex off; # "on" if nginx worker_processes > 1
  use epoll; # enable for Linux 2.6+
  # use kqueue; # enable for FreeBSD, OSX
}

http {
  # nginx will find this file in the config directory set at nginx build time
  #include /usr/local/nginx/conf/mime.types;

  # fallback in case we can't determine a type
  default_type application/octet-stream;

  # click tracking!
  #access_log /tmp/nginx.access.log combined;
  access_log off;

  upstream nimrod {
    server 127.0.0.1:9000;
    server 127.0.0.1:9001;
    server 127.0.0.1:9002;
    server 127.0.0.1:9003;
    server 127.0.0.1:9004;
    server 127.0.0.1:9005;
    server 127.0.0.1:9006;
    server 127.0.0.1:9007;
  }

  server {
    # enable one of the following if you're on Linux or FreeBSD
    listen 8080 default deferred; # for Linux
    # listen 80 default accept_filter=httpready; # for FreeBSD

    client_max_body_size 4G;
    server_name _;

    # ~2 seconds is often enough for most folks to parse HTML/CSS and
    # retrieve needed images/icons/frames, connections are cheap in
    # nginx so increasing this is generally safe...
    keepalive_timeout 10;

    # path for static files
    root /path/to/app/current/public;

    # Prefer to serve static files directly from nginx to avoid unnecessary
    # data copies from the application server.
    #
    # try_files directive appeared in in nginx 0.7.27 and has stabilized
    # over time.  Older versions of nginx (e.g. 0.6.x) requires
    # "if (!-f $request_filename)" which was less efficient:
    # http://bogomips.org/unicorn.git/tree/examples/nginx.conf?id=v3.3.1#n127
    #try_files $uri/index.html $uri.html $uri @app;

    location / {
      #include /usr/local/nginx/conf/scgi_params;
      #scgi_pass nimrod;
      proxy_pass http://nimrod;
    }

  }
}
