Nginx Log Top IP

Today access.log

    207 216.244.66.241
    136 66.249.75.37
    125 66.249.75.38
    121 220.185.158.162
     92 216.73.216.13
     90 66.249.75.39
     90 106.56.105.103
     78 14.216.154.204
     63 14.153.204.159
     62 111.221.214.61
     61 111.221.214.151
     60 212.34.135.52
     59 111.221.213.19
     58 115.45.43.10
     57 89.110.80.171
     56 45.32.133.201
     55 115.45.41.247
     54 115.45.41.82
     52 14.155.225.138
     52 14.155.224.95

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