'GoAccess Set the WebSocket server to listen on port 7890 and localhost

I'm trying to run a GoAccess example:

# goaccess -f access.log -o report.html --real-time-html

There's either

Parsing... [41] [0/s]

OR no output in the terminal. I wait a long time. Then CTRL+C:

^CSIGINT caught!
Stopping WebSocket server...

Maybe I'm missing a step in:

"To output an HTML report and set the WebSocket server to listen on port 7890 and localhost."

"Connection Reset" at my.ip.address.here:7890.

I'm guessing that nginx is not involved in this, as it's logs are only showing calls to other web pages.

Is there some other configuration or logs I might want to look into?

UPDATE:

A little more clear and have gotten this far:

$ sudo goaccess -f /var/log/nginx/access.log.1 -o /usr/share/nginx/www/report.html \\
--real-time-html --ws-url=domain.com
Parsing... [84] [0/s]

I can:

telnet domain.com 7890
Trying 45.55.xxx.xxx...
Connected to domain.com.
Escape character is '^]'.

In the browser: domain.com:7890/report.html returns Connection Reset.

Would someone clarify what this path is supposed to represent:

/usr/share/nginx/www/report.html

Is report.html supposed to actually exist and does the path need to be to a specific place in the Server's System?



Solution 1:[1]

I had some problems getting the realtime reports to work and eventually found out why they were not working for me. This may / may not apply to you.

I was generating the realtime report in the directory of my website which runs over SSL. Unfortunately Goaccess realtime reports do not work over SSL at all.

What I did to resolve this was I set up a new domain goaccess.mydomain.com and set it to run on port80 on Nginx. Then protected the / location with an .htpasswd file and then I generate the realtime reports into that new web site's folder.

The static reports work 100% over SSL just not the realtime.

So what I do now everyday using Cron is generate the realtime reports for the sites I want to monitor using.

goaccess -f /var/log/nginx/site1-access.log -a -o /var/www/goaccess.mydomain.com/site1.html
goaccess -f /var/log/nginx/site2-access.log -a -o /var/www/goaccess.mydomain.com/site2.html

then when I want a realtime report on a certain site I just run

goaccess -f /var/log/nginx/site1-access.log -a -o /var/www/goaccess.mydomain.com/site.html.html --real-time-html --ws-url=goaccess.mydomain.com

I have asked them to note the https problem in their documentation as this had me going in circles for ages.

Solution 2:[2]

Quoting from GoAccess' website:

The process of generating a real-time HTML report is very similar to the process of creating a static report.

Just generate a static report and place the output html file under your web server www public folder. You need to add a couple of additional real-time flags. The use of --real-time-html is required.

# goaccess -f access.log -o /usr/share/nginx/www/rt.goaccess.io/report.html --real-time-html --ws-url=host 

Upon opening the generated report in your browser, the report will try to establish a WebSocket connection to the host specified by --ws-url=. Note that the host should point to the location where GoAccess is running and parsing logs. Also, make sure host is a valid host and should not contain http on it.

If you don't use --ws-url, it will attempt to establish the WebSocket connection to localhost, which means that GoAccess should be running on your local machine (the same machine running the browser)

From the man page, it appears that GoAccess runs on port 7890 by default. As it states, you probably want to specify --ws-url to specify the location of GoAccess WebSocket server, unless your access log is located on your local machine.

Solution 3:[3]

For ssl add these params to the command:

--ssl-cert=<cert.crt> and --ssl-key=<priv.key>.

If still stuck the port sometimes needs opening

iptables -A INPUT -i eth0 -p tcp --destination-port 7890 -j ACCEPT

I've also noticed, it needs the target output file to exist at the path specified, it will then write into the file. It will never create it for some reason.

Solution 4:[4]

To output real time data over a TLS/SSL connection, you need to use --ssl-cert=<cert.crt> and --ssl-key=<priv.key>.

Worked for me :)

Solution 5:[5]

coming late tho, this is what i think the documentation described and i am going to walk you in steps. first of all run the command like so

i am using NGINX as my server

$goaccess /var/log/nginx/access.log -o /var/www/goaccess/report.html --real-time-html --ssl-cert=/path/to/cert --ssl-key=/path/to/key

you sould see this next after you eneterd the command

 [PARSING /var/log/nginx/access.log] {123} @ {0/s}
 WebSocket server ready to accept new client connections

now ctrl ^C to quit and go to your nginx server config in my case /etc/nginx/sites-available/mysite and edit it. Add the following block to your server context or block

location /goaccess/ {
   root /var/www;
}

then check if config file is ok and reload nginx like so

sudo nginx -t 
sudo nginx -s reload

next run the first command (goaccess command) again to start the socket server then navigate to https://example.com/goaccess/report.html you should now see the report and a green dot on the settings icon showing that the socket server is active and is auto updating report.html you could also try seeing if it works by navigating to another tab and entering https://example.com and coming back to check if there was a change in the logs/statistics.

You can now quit the socket server and try making it a system service

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 MitchellK
Solution 2 Sijia Din
Solution 3 blissweb
Solution 4 Angela Amarapala
Solution 5 goodnews john