Nginx Log Top IP

Today access.log

    480 216.244.66.241
    411 66.249.75.37
    389 216.73.216.13
    372 66.249.75.38
    356 171.104.83.73
    258 66.249.75.39
    228 106.56.105.103
    219 223.99.125.94
    191 111.221.214.151
    172 115.45.43.10
    169 111.33.2.83
    167 14.155.212.109
    166 121.10.198.7
    158 220.185.158.162
    158 115.45.41.247
    158 106.117.96.6
    154 111.221.213.19
    153 14.153.204.159
    153 116.76.36.125
    150 115.45.41.82

Yesterday access.log.1

   1398 20.171.207.69
    871 144.76.19.147
    724 185.177.72.202
    503 216.73.216.49
    454 216.244.66.241
    421 66.249.64.108
    333 66.249.64.109
    262 171.104.83.73
    251 106.56.105.103
    244 185.177.72.111
    231 66.249.64.110
    223 121.10.198.7
    216 14.216.154.204
    212 123.88.53.127
    167 183.253.117.141
    163 65.108.0.71
    153 218.26.159.0
    151 216.73.216.146
    145 111.33.2.83
    144 106.117.96.6

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