RubyonRailsMongrel

= Ruby on Rails / Mongrel =

user deploy; worker_processes 1; error_log  logs/error.log debug;

events { worker_connections 1024; }

http { include       conf/mime.types; default_type  application/octet-stream; sendfile       on; #tcp_nopush    on; keepalive_timeout 65; tcp_nodelay       on;

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

upstream mongrel { server 127.0.0.1:8000; server 127.0.0.1:8001; } server { listen      80; server_name example.com; root        /var/www/apps/example/current/public; index       index.html index.htm; try_files $uri/index.html $uri.html $uri @mongrel; location @mongrel { proxy_set_header X-Real-IP        $remote_addr; proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for; proxy_set_header Host             $http_host; proxy_redirect   off; proxy_pass       http://mongrel; }   error_page   500 502 503 504  /50x.html; location = /50x.html { root  html; } } }

= FAQ =

Multiple mongrel instances?
Never run only a single mongrel instance, Rails is not thread safe. 90% of the time you need to run TWO in order to get any level of acceptable performance.

proxy_redirect?
I noticed on some apps that redirections break. It seems it was stripping the proxy_pass from the redirection url:

upstream beast { ... } proxy_pass http://beast;

In my rails production log I see "Redirected to http://beast.caboo.se/login". However, livehttpheaders only sees '.caboo.se/login'. Adding the proxy_redirect false; above fixes it.