Nginx Log Top IP

Today access.log

    532 43.156.232.154
    507 43.165.129.89
    493 43.134.93.164
    477 43.156.79.172
    437 43.134.163.229
    372 62.197.157.40
     82 193.70.81.126
     80 66.249.79.237
     72 194.50.16.252
     70 66.249.79.236
     70 43.173.1.57
     67 66.249.79.238
     62 43.133.139.6
     62 106.56.105.103
     61 27.200.42.196
     60 171.95.79.61
     59 43.173.1.69
     57 45.148.10.97
     56 43.163.104.54
     56 43.156.232.190

Yesterday access.log.1

   1179 43.165.129.89
   1124 43.134.163.229
   1096 43.156.79.172
   1005 43.134.93.164
    994 43.156.232.154
    786 180.118.187.19
    325 183.42.132.68
    263 216.244.66.241
    222 121.10.198.7
    201 117.132.188.205
    145 43.173.1.57
    129 43.133.139.6
    128 43.173.1.69
    125 43.134.186.61
    121 223.90.130.41
    120 43.163.104.54
    120 43.156.232.190
    119 43.153.192.98
    116 43.153.204.189
    115 111.33.88.87

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