zl程序教程

您现在的位置是:首页 >  系统

当前栏目

在Centos中使用goaccess查看Nginx日志

centos日志Nginx 查看 使用
2023-09-27 14:28:13 时间

在Nginx的配置文件中配置一下access日志:

 log_format access ‘$remote_addr – $remote_user [$time_local] “$request” ‘‘$status $body_bytes_sent “$http_referer” ‘‘”$http_user_agent” $http_x_forwarded_for’;
 access_log  /usr/local/openresty/nginx/logs/access.log;

 

安装一下goaccess:

yum -y install glib2 glib2-devel ncurses ncurses-devel geoip geoip-devel

cd /usr/local
wget http://tar.goaccess.io/goaccess-0.9.2.tar.gz
tar zxvf goaccess-0.9.2.tar.gz
cd goaccess-0.9.2
./configure --enable-geoip --enable-utf8
make && make install
make clean


3. GoAccess 使用方法
进入 Nginx 日志所在目录

命令行直接查看
cd /usr/local/openresty/nginx/logs

goaccess -f access.log

出来图了,日志格式选 NCSA

http://www.fancycoding.com/log-analyse-using-goaccess/

禁止IP访问:
iptables -I INPUT -s 222.35.67.155 -j DROP
恢复IP访问:
iptables -D INPUT -s 222.35.67.155 -j DROP

 

查看网卡:

nload -m eth1