Nginx Log Top IP

Today access.log

    699 144.76.88.54
     50 14.155.183.150
     47 120.237.87.26
     44 14.155.184.3
     41 66.249.77.4
     32 66.249.77.6
     31 120.237.85.78
     26 66.249.77.5
     25 114.24.133.14
     21 203.160.72.112
     21 124.108.6.150
     19 183.42.208.227
     18 203.160.68.16
     16 172.233.75.10
     16 111.55.148.14
     14 52.167.144.183
     14 182.239.92.143
     14 182.239.92.139
     13 45.79.93.48
     13 182.239.92.201

Yesterday access.log.1

   7112 44.201.134.97
   7110 158.220.105.45
   6244 147.45.47.92
   2510 167.172.106.24
   1546 144.76.88.54
    683 14.155.184.3
    612 120.237.87.26
    593 120.216.162.253
    444 14.155.183.150
    419 120.237.85.78
    299 199.127.60.228
    280 66.249.66.67
    270 66.249.66.68
    189 66.249.66.69
    174 171.104.83.82
    169 62.112.11.42
    161 171.105.200.217
    151 121.10.198.7
    121 172.233.75.10
    120 222.175.233.118

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