Nginx 日志 IP 统计

Today access.log

    391 36.156.79.93
    388 36.156.79.37
    386 36.156.79.41
    164 47.117.201.150
    161 47.117.201.193
    159 47.117.201.227
    159 47.117.201.214
    159 47.117.201.194
    159 47.117.201.178
    158 47.117.201.167
    157 47.117.201.196
    156 47.117.201.189
    156 47.117.201.174
    155 47.117.201.212
    155 47.117.201.204
    154 47.117.201.223
    154 47.117.201.181
    153 47.117.201.222
    151 47.117.201.171
    150 47.117.201.155

Yesterday access.log.1

   1536 36.156.79.93
   1502 36.156.79.41
   1499 36.156.79.37
    758 118.31.144.48
    737 118.31.144.62
    727 118.31.144.80
    720 118.31.144.54
    719 118.31.144.52
    715 118.31.144.66
    707 118.31.144.94
    707 118.31.144.27
    702 118.31.144.24
    701 118.31.144.95
    700 118.31.144.97
    700 118.31.144.79
    696 118.31.144.96
    695 118.31.144.92
    690 118.31.144.81
    689 118.31.144.77
    687 118.31.144.89

“Knowing is not enough, we must apply. Willing is not enough, we must do.” 🚢

✍ 功能简介

统计 Nginx 日志(access.log)中的请求量排名前 20 的 IP。 方便判断是否有恶意 IP 请求,或者非正规搜索引擎的爬虫 IP。

💻 Nginx 命令

$ awk '{print $1}' access.log | sort | uniq -c | sort -rn | head -n 20

📈 历史统计

累计使用次数:385