I'm trying to make a CGI script (for nginx) that outputs an html page containing the usage statistics for my server. I'm using goaccess 0.7.1 and CentOS 5 x86.
I've configured nginx to run my bash script (stats.sh) for requests on port 8080.
The bash script looks like this:
#!/bin/bash
cat /var/log/nginx/mydomain.access.log | goaccess -a > stats.html
echo Content-Type: text/html
echo Content-Length: $(stat -c%s stats.html)
echo
cat stats.html
When I run ./stats.sh, everything works fine. It prints a bunch of html code in the console window, and if I open stats.html, I see a bunch of html code.
THE PROBLEM IS, when I try to access http://www.mydomain.com:8080/, I just get a blank page. Now when I open stats.html on the server, it's completely empty.
I've confirmed the following permissions:
stats.sh:-rwxr-xr-xstats.html:-rw-rw-rw-goaccess:-rwxr-xr-x
I also know that CGI is working properly because if I modify stats.sh to only output the contents of stats.html (without writing to the file), it works fine when I hit http://www.mydomain.com:8080/; it just sends whatever data was in stats.html from before. So something is going wrong with calling goaccess in a CGI script. Does anyone know why?
UPDATE
I also tried this:
echo "<!DOCTYPE hmtl><html><body>TEST</body></html>" > stats.html
and it works fine when I hit http://www.mydomain.com:8080/, so something is going wrong when running goaccess from FastCGI.
I also tried specifying the full path to goaccess (/usr/local/bin/goaccess):
/var/log/nginx/mydomain.access.log | /usr/local/bin/goaccess -a >stats.html 2>stats.err
but this also did not work.
/var/log/nginx/nginx_error.log?014/08/07 20:05:51 [error] 24993#0: *610 access forbidden by rule, client: x.x.x.x, server: _, request: "GET /manager/html HTTP/1.1", host: "x.x.x.x:8080". I don't have a page called/manager/html, nor did I ever request it, so I assume this is from a crawler. All of the errors from the last 2 days are similar to this one.chmod a+rwx /usr/lib/cgi-binand it worked fine. I'll see if I can fire up an nginx instance and test it.goaccess -a >stats.html 2>stats.err2>stats.errpart, but it doesn't generate thestats.errfile at all when I run it from FastCGI. If I run the bash script manually, it generatesstats.erras an empty file.