Nginx Log Top IP

Today access.log

     37 120.245.94.9
     27 66.249.73.198
     21 66.249.73.197
     18 35.206.99.182
     15 216.244.66.241
     12 223.160.230.117
     12 112.3.213.244
     10 71.131.194.239
     10 66.249.73.199
     10 182.239.117.179
     10 140.179.104.233
     10 111.16.86.129
      9 54.223.79.176
      9 54.223.171.85
      9 218.82.53.204
      9 101.8.130.158
      8 64.124.8.196
      8 221.193.78.38
      8 120.229.48.3
      8 116.204.105.34

Yesterday access.log.1

   2696 43.153.110.86
    558 66.249.79.6
    519 66.249.79.7
    356 216.244.66.241
    353 66.249.79.8
    300 188.165.241.181
    249 217.182.175.163
    218 81.71.5.172
    185 120.229.48.3
    180 106.117.76.81
    176 121.10.198.7
    154 123.182.226.103
    151 217.182.195.225
    148 222.212.192.0
    134 172.233.75.10
    131 119.129.50.126
    130 111.33.88.87
    116 223.99.125.94
    106 27.185.72.194
    106 112.122.28.84

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