1.安装
#安装依赖
yum -y install libmaxminddb-devel ncurses-libs ncurses-devel openssl openssl-devel
#下载源码
wget https://tar.goaccess.io/goaccess-1.2.tar.gz
#解压
tar -xzvf goaccess-1.2.tar.gz
#进入目录
cd goaccess-1.2/
#编译安装
./configure --enable-utf8 --enable-geoip=mmdb --with-openssl --with-libmaxminddb-devel
make && make install
2.配置nginx
对应的Nginx 日志目录
[root@backend-dev ] goaccess /opt/nginx/logs/access.log -o /opt/nginx/goaccess/report.html --real-time-html --time-format='%H:%M:%S' --date-format='%d/%b/%Y' --log-format=COMBINED
在nginx.conf 中对应server内加入如下配置:
location /report.html {
alias /opt/nginx/goaccess/report.html;
}
重启Nginx,访问localhost:8080/report.html可以看到如图所示:
3. 配置认证
对应的nginx目录
yum -y install httpd-tools
htpasswd -c pass.db root
在nginx.conf文件中配置auth_basic 和 auth_basic_user_file
location / {
auth_basic "goaccess-login!";
auth_basic_user_file 对应的nginx目录/pass.db;
alias /opt/nginx/goaccess/report.html;
}
|