Nginx as a reverse proxy for long polling

I have apache as an internal server that runs php scripts and nginx as a reverse proxy that deals with static content. A php script that gives me the identifier of some process and then executes this process (rather long). I need to pass to the browser only the identifier of this process.

  // ...
  ob_start();

  echo json_encode($arResult); // only this data should be passed to browser

  $contentLength = ob_get_length();
  header('Connection: close');
  header('Content-Length: ' . $contentLength);

  ob_end_flush();
  ob_flush();
  flush();
  // then performed a long process

(I check the status of the process with another ajax-script)

This works just fine under Apache. But I have problems when apache is behind nginx. In this case, I get a response only when the process is complete.

Nginx settings:

server {
  #...
  proxy_set_header Connection close;

  proxy_pass_header Content-Length;
  #...
}

But I still get Connection keep-alive in FireBug.

How can I get nginx to immediately give an answer from apache?

Hope the question is clear.

Thank.

+5
3

proxy_buffering nginx? , , , .: -)

+5

Nginx - flush() PHP fastcgi reverse_proxy.

proxy_buffering_ *, buffer_size_ * nginx/0.8.49. PHP-.

0
0

All Articles