read

Fairly easy. The important line here is: proxy_buffering off;

I think this one works at least for most Rack based applications. The application itself runs on thin ( besides that, I only know Unicorn and Rainbow(s?) that have Streaming Support. Webrick won't do that (yet))

My vhost config.

upstream stream {
  server 127.0.0.1:4800;
  server 127.0.0.1:4801;
  server 127.0.0.1:4802;       
  server 127.0.0.1:4803;       
  server 127.0.0.1:4804;   
}
    
server {
  listen   80;
  server_name  stream.domain.com;
  client_max_body_size 5M;  
  root /path/to/project/current/public;
  error_log /path/to/project/shared/nginx/stream.error.log;   
  access_log  off;
  location / {        
    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_buffering off;
    proxy_redirect off;

    if (-f $request_filename) { 
      break; 
    }
    
    if (!-f $request_filename) {
      proxy_pass http://stream;
      break;
    }
    
  }
}
Back to Overview