惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - zjhgx

hjdang 从jdk11升级到jdk25遇到的问题 腾讯云服务器遭受大量请求攻击导致网页打不开 capacitor的android项目接入穿山甲遇到的坑 class file for org.apache.shiro.lang.util.Nameable not found class file for org.apache.shiro.lang.util.Nameable not found 使用capacitor遇到的问题记录 shiro的cookie去掉domain后导致用户无法登陆 android真机调试遇到的问题 用java爬取京东商品页注意点 SEO 经验记录 nginx日志按天分割 记一次流量爆发导致服务器无响应的记录 mac 安装完Navicat Premium 提示已损坏 无法打开的处理方法 腾讯云问题汇总 vue-element-admin npm install 错误 quasar <q-page>下面<div>自动计算height的问题 Adsense遇到的问题 web项目启动时dubbo报错: No provider available for the service com.davidhu.shopguide.api.service.UserEventService from the url zookeeper ://localhost:2181/org.apache.du quasar ssr模式出现了CLS issue vue ssr里面在template不能出现this,create时this还没有
使用goaccess统计nginx日志
zjhgx · 2024-06-10 · via 博客园 - zjhgx

网站已经用了百度统计,但现在移动端的浏览器,如夸克,UC等默认都禁广告,同时也会阻止统计的js运行,所以百度统计只能统计到一部分。

可以用脚本来在nginx日志中统计URL但比较麻烦,在网上搜了一下统计nginx的工具,发现有个goaccess还比较方便。

安装依赖库:

yum install -y GeoIP-devel ncurses-devel

安装:

$ wget https://tar.goaccess.io/goaccess-1.9.3.tar.gz
$ tar -xzvf goaccess-1.9.3.tar.gz
$ cd goaccess-1.9.3/
$ ./configure --enable-utf8 --enable-geoip=mmdb
$ make
# make install

遇到的问题:

1.日志格式的配置

由于我的nginx日志格式不是默认的,当初是由于nginx要按天出日志做过修改

    # 日志按天分割
    log_format main '$remote_addr - $remote_user [$time_iso8601] "$request" '
      '$status $body_bytes_sent "$http_referer" '
      '"$http_user_agent" "$http_x_forwarded_for" "$request_body"';
114.119.141.127 - - [2024-06-09T00:00:12+08:00] "GET /d/184833 HTTP/1.1" 200 6857 "https://www.hjdang.com/d/184834" "Mozilla/5.0 (Linux; Android 7.0;) AppleWebKit/537.36 (KHTML, like Gecko) Mobile Safari/537.36 (compatible; PetalBot;+https://webmaster.petalsearch.com/site/petalbot)" "-" "-"

看网上都是下面这种配置

配置文件位于:/usr/local/etc/goaccess/goaccess.conf

1
2
3
time-format %H:%M:%S
date-format %d/%b/%Y
log-format %h - %^ [%d:%t %^]; "%r" %s %b "%R" - %^"%u" - %^ %T

搞了好久,还用了一个工具转化(不行),终于配置好了。配置如下:

time-format %H:%M:%S
date-format %Y-%m-%d
log_format %h - %^ [%dT%t+%^] "%r" %s %b "%R" "%u" "%^""%^"

2. 实时html不刷新

goaccess www.hjdang_2024-06-08.log  -o /data/file/goaccess/report.html --real-time-html

生成实时html发现刷新不了,后来才知道是websocket的端口7890没有开

3. --daemonize没有用

后台运行参数--daemonize不起作用,加上后命令无效。后来才知道要www.hjdang_2024-06-08.log 要用绝对路径

goaccess -f /data/log/nginx/www.hjdang_2024-06-08.log  -o /data/file/goaccess/report.html --real-time-html --daemonize