This solution/configuration solved my 400 and 502 errors
nginx conf [ key point ]
upstream goaccess {
server localhost:7890;
keepalive 60;
}
server {
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/test.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/test.com/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
server_name rp.test.com;
root /var/www/goaccess;
index index.html;
location / {
try_files $uri $uri/ @goaccess;
alias /var/www/goaccess/;
index index.html;
proxy_set_header Upgrade $http_upgrade;
proxy_buffering on;
proxy_set_header Connection "Upgrade";
proxy_connect_timeout 600s;
proxy_send_timeout 600s;
proxy_read_timeout 600s;
proxy_temp_path /var/nginx/proxy_temp;
}
location @goaccess{
proxy_pass http://goaccess;
}
}
goaccess [ goaccess.sh ]
#!/bin/sh
goaccess /root/test2_nginx_log/www.test2.com_access.log -o /var/www/goaccess/index.html --real-time-html --origin=https://rp.test.com --addr=0.0.0.0 --port=7890 --ws-url=wss://rp.test.com --ssl-cert=/etc/letsencrypt/live/test.com/fullchain.pem --ssl-key=/etc/letsencrypt/live/test.com/privkey.pem --time-format=%H:%M:%S --date-format=%d/%b/%Y --log-format=COMBINED
sshfs [ run_sshfs.sh ]
#!/bin/sh
if [ $(mount | grep 'root@111.111.111.xxx:/data/log/server/nginx' | wc -l) -ne 1 ]
then
echo 'yourpassword' | sshfs root@111.111.111.xxx:/data/log/server/nginx /root/test2_nginx_log -o password_stdin,allow_other
else
exit 0
fi
Finally this sh for check goaccess was running or not and the mount was online or not then restart that.
check and restart [ cr.sh ]
#!/bin/bash
if pgrep -x "goaccess" > /dev/null
then
clear ;
echo "goaccess is running!"
sleep 1
echo "now cutting down goaccess...please wait"
sleep 2
kill `pgrep goaccess`
echo "cut down done"
sleep 1
echo "now check mount test2 nginx log folder..."
cd /root/ && ./run_sshfs.sh
sleep 2
echo "mount done"
sleep 1
echo "now restart goaccess..."
cd /root/ && sudo nohup ./goaccess.sh > goaccess.log 2>&1 &
sleep 2
echo "goaccess was restarting success!"
sleep 1
echo "now all done!"
exit 1
else
clear ;
echo "goaccess is down!"
sleep 1
echo "now check mount test2 nginx log folder..."
cd /root/ && ./run_sshfs.sh
sleep 2
echo "mount done"
sleep 1
echo "now start goaccess..."
cd /root/ && sudo nohup ./goaccess.sh > goaccess.log 2>&1 &
sleep 2
echo "goaccess was starting success!"
sleep 1
echo "now all done!"
fi
That all. Now open your url which looks like my 'rp.test.com' you should see something similar below (if without any other special condition).
Running:

Notice: This is CROTEL's solution initially posted in question, subsequently moved by community members to a community wiki answer to conform to Stack Overflow's Q/A format