title: How to use comet (disable output buffering in nginx, it works in apache normally but not nginx)?
body: <p>I have a comet-driven chat script in my site </p>
  
  <p>My Servers configuration is  NGINX with PHP-FPM ,  I also have apache installed on different port.</p>
  
  <p>When I try to run the chat script on Apache and I do flood the buffer ( my output buffering size is 1 KB) when I flood it with 1024 character, it flushes automatically That's in apache.</p>
  
  <p>But in nginx it doesn't.</p>
  
  <p>My code is very similar to this</p>
  
  <pre><code>&lt;?php
  
  // this is to fill the buffer and start output; and it works on apache normally
  echo str_repeat(" ",1024); 
  
  
  while($condition){
  
    // Some code here...
    $messages = getMessagesFromDatabase();
  
   if($messages){
    echo "output";   // output works on apache but not nginx
    flush();
    ob_flush();
   }
  
   usleep(500000); // 0.5 Second
  
  }
  
  
  ?&gt;
  </code></pre>
  
  <p>in my nginx configuration i turned gzip off, proxy_buffering off, </p>
  
  <p>is there a way to avoid buffering in nginx, I searched a lot here in stackoverflow but I couldn't reach to a solution </p>
  
  <p><strong>and please notice: I don't want to turn off buffering in all of my php configuration I just want this to happen in the chat script</strong></p>