Server Fault Asked by Crash Override on October 10, 2020
I have a perl and shell script that process a bunch of data and output results as they happen, like:
5 processed in 0.58 seconds.
10 processed in 0.79 seconds.
...
150 processed in 0.65 seconds. DONE!
etc.
However, when I visit the URL with Chrome, it shows nothing, waits until the script finishes, then shows the entire output at once. Is there a way to configure nginx to show each line output as it happens? I used to be able to do this with Apache.
I put gzip off
in the nginx config, thinking this could nginx waiting to compress the text before sending it to the client, but that did not help.
I also tried buffer-flushing techniques in the scripts themselves, like these lines at the top of my Perl scripts:
use IO::Handle;
$| ++;
STDERR->autoflush(1);
STDOUT->autoflush(1);
print "Content-type: text/plainnn";
Relevant parts of the nginx config look like this
ssl on;
root /my/path/cgi ;
proxy_read_timeout 900s ;
fastcgi_read_timeout 900s ;
fastcgi_request_buffering off ;
gzip off ;
location ~ .pl|cgi$ {
try_files $uri =404;
gzip off;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
Any ideas?
You need to tell nginx to not buffer the response from the FastCGI server, with fastcgi_buffering off;
.
From the docs:
When buffering is disabled, the response is passed to a client synchronously, immediately as it is received. nginx will not try to read the whole response from the FastCGI server. The maximum size of the data that nginx can receive from the server at a time is set by the fastcgi_buffer_size directive.
Which you may also need to tweak.
But in general, a plain HTML web page is probably not the best interface for whatever it is you're doing.
Answered by Michael Hampton on October 10, 2020
0 Asked on January 30, 2021 by charliephp
0 Asked on January 30, 2021 by harshikesh-kumar
1 Asked on January 30, 2021 by gm777
1 Asked on January 30, 2021 by darinth
1 Asked on January 29, 2021
1 Asked on January 29, 2021 by rplaurindo
2 Asked on January 28, 2021 by ericr
2 Asked on January 28, 2021 by anthony-kong
1 Asked on January 28, 2021 by ksg
4 Asked on January 28, 2021 by snoweagle
1 Asked on January 27, 2021 by bruce
3 Asked on January 27, 2021
1 Asked on January 27, 2021 by eric-falsken
1 Asked on January 27, 2021 by khyathi
1 Asked on January 27, 2021 by stein-smul
disk space utilization installation msi uninstall windows installer
0 Asked on January 27, 2021 by jake-barnett
1 Asked on January 26, 2021 by julien-g
2 Asked on January 26, 2021 by arne-z
Get help from others!
Recent Questions
Recent Answers
© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP