#user  nobody;
worker_processes 1;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#pid logs/nginx.pid;


events {
worker_connections 1024;
}


http {
#include conf/mime.types;
default_type application/octet-stream;

# no sendfile on OSX uncomment
#this if your on linux or bsd
#sendfile on;
tcp_nopush on;

keepalive_timeout 65;
tcp_nodelay on;

upstream merb_app {
server 127.0.0.1:4000;
server 127.0.0.1:4001;
server 127.0.0.1:4002;
}

gzip on;
gzip_min_length 1100;
gzip_buffers 4 8k;
gzip_types text/plain;

server {
listen 80;
#server_name localhost;
root /Users/bryan/Sites/merb/my_merb_app/public;

access_log off;
rewrite_log on;

location ~ ^/$ {
if (-f /index.html){
rewrite (.*) /index.html last;
}
proxy_pass http://merb_app;
}

location / {
if (!-f $request_filename.html) {
proxy_pass http://merb_app;
}
rewrite (.*) $1.html last;
}

location ~ .html {
root /Users/bryan/Sites/public;
}

location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|mov)$ {
root /Users/bryan/Sites/merb/my_merb_app/public;
}

location / {
proxy_pass http://merb_app;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

}
}