Hi all,
I'm currently stuck on a small problem with my cgi. I want to disable buffering but it doesn't seems to work !
Here is my current test conf (I tested some stuff before posting here) :
server {
listen 80 default_server;
#listen [::]:80 default_server;
root /var/www/;
server_name localhost;
location / {
try_files $uri $uri/ =404;
}
location /cgi-bin/ {
fastcgi_pass unix:/var/run/fcgiwrap.socket;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
gzip off;
fastcgi_buffering off;
fastcgi_request_buffering off;
}
}
Here is my C test script :
#include <unistd.h>
#include <stdio.h>
#include <string.h>
int main(void) {
char entete[] = "HTTP/1.1 200 OK\nX-Accel-Buffering: no;\nCache-Control: no-cache;\nTransfer-Encoding: chunked;\nContent-Type: text/html;charset=UTF-8;\n\n";
write(1, entete, strlen(entete));
char debut[] = "<html><head><title>Hello World!! </title></head>\n<body><h1>Hello world</h1>\n";
write(1, debut, strlen(debut));
for(int i = 1; i <= 10; i++) {
char msg[] = "<h3>Print</h3>\n";
write(1, msg, strlen(msg));
sleep(1);
}
return 0;
}
CGI are working but it wait the end of the cgi execution to send all data to the browser, but for my project, where I use event streaming, it will not work cause the cgi will be executed endlessly so no data will be send to the browser. So I need to disable this sort of buffer.
Also, I'm using the last version of Nginx (1.9.0) and Fcgiwrap !
Thanks for your future help !
I'm currently stuck on a small problem with my cgi. I want to disable buffering but it doesn't seems to work !
Here is my current test conf (I tested some stuff before posting here) :
server {
listen 80 default_server;
#listen [::]:80 default_server;
root /var/www/;
server_name localhost;
location / {
try_files $uri $uri/ =404;
}
location /cgi-bin/ {
fastcgi_pass unix:/var/run/fcgiwrap.socket;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
gzip off;
fastcgi_buffering off;
fastcgi_request_buffering off;
}
}
Here is my C test script :
#include <unistd.h>
#include <stdio.h>
#include <string.h>
int main(void) {
char entete[] = "HTTP/1.1 200 OK\nX-Accel-Buffering: no;\nCache-Control: no-cache;\nTransfer-Encoding: chunked;\nContent-Type: text/html;charset=UTF-8;\n\n";
write(1, entete, strlen(entete));
char debut[] = "<html><head><title>Hello World!! </title></head>\n<body><h1>Hello world</h1>\n";
write(1, debut, strlen(debut));
for(int i = 1; i <= 10; i++) {
char msg[] = "<h3>Print</h3>\n";
write(1, msg, strlen(msg));
sleep(1);
}
return 0;
}
CGI are working but it wait the end of the cgi execution to send all data to the browser, but for my project, where I use event streaming, it will not work cause the cgi will be executed endlessly so no data will be send to the browser. So I need to disable this sort of buffer.
Also, I'm using the last version of Nginx (1.9.0) and Fcgiwrap !
Thanks for your future help !