Nginx Log Top IP

Today access.log

    374 39.144.168.92
    317 222.85.197.2
    296 125.38.49.192
    193 117.132.188.205
    157 122.227.36.90
    129 27.27.235.157
    121 66.249.75.37
    112 119.129.225.112
    112 116.22.248.150
    109 66.249.75.38
    103 195.178.110.159
    102 171.105.200.248
     99 14.155.235.51
     97 121.10.198.7
     95 66.249.75.39
     94 14.155.227.19
     93 171.104.83.127
     87 172.233.75.10
     87 113.221.41.215
     86 49.85.62.11

Yesterday access.log.1

    467 81.71.5.172
    318 216.244.66.241
    300 194.247.173.99
    297 183.222.174.201
    248 178.18.254.165
    223 106.55.200.246
    204 121.10.198.7
    195 66.249.75.38
    193 117.132.188.205
    189 66.249.75.37
    187 106.55.200.45
    171 195.178.110.163
    147 66.249.75.39
    147 111.33.2.83
    143 106.117.98.146
    141 45.125.66.108
    139 14.155.190.232
    138 183.134.128.204
    137 202.113.189.134
    132 183.47.105.49

Introduction

Statistics for Nginx based on the access.log file: Count the number of unique IP addresses. Determine whether each IP is allowed or denied based on the request, and provide details on any blocked IPs.

Command

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