[英]How can I get Goaccess running under Nginx?
I need to configure Nginx to make Goaccess work. 我需要配置Nginx才能使Goaccess正常工作。
My environment is: 我的环境是:
Since this is a self-answered Q/A I'm not including my failed attempts, but instead posting my solution. 由于这是一个自我解答的问题,因此我不包括失败的尝试,而是发布解决方案。 Feel free to edit it or post another answer improving the current code .
随时编辑它或发布另一个答案以改进当前代码 。
This solution/configuration solved my 400 and 502 errors 此解决方案/配置解决了我的400和502错误
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;
}
}
#!/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
#!/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. 最终,此sh检查goaccess是否正在运行,并且挂载是否在线,然后重新启动它。
#!/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).
现在打开看起来像我的“ rp.test.com”的URL,您应该在下面看到类似的内容(如果没有其他特殊条件)。
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
注意:这是CROTEL的解决方案,最初是有问题的 ,后来由社区成员转移到社区Wiki答案中,以符合Stack Overflow的Q / A格式
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.