Nginx Log Top IP

Today access.log

   7112 44.201.134.97
   7110 158.220.105.45
   6244 147.45.47.92
   2510 167.172.106.24
    593 120.216.162.253
    424 14.155.184.3
    355 120.237.87.26
    299 199.127.60.228
    287 14.155.183.150
    268 120.237.85.78
    194 66.249.66.68
    184 66.249.66.67
    169 62.112.11.42
    133 66.249.66.69
    120 222.175.233.118
    115 144.12.182.180
    113 171.104.83.82
    112 171.105.200.217
    100 216.244.66.241
    100 121.10.198.7

Yesterday access.log.1

    738 144.76.88.54
    466 14.155.184.3
    428 120.237.87.26
    365 66.249.77.4
    320 120.237.85.78
    286 66.249.77.5
    280 14.155.183.150
    276 218.201.252.29
    263 66.249.77.6
    255 183.238.254.42
    248 94.23.203.202
    248 135.181.212.177
    213 122.191.192.60
    186 183.239.175.174
    175 222.248.73.173
    175 111.85.31.23
    158 216.244.66.241
    157 188.165.217.198
    135 125.123.184.73
    120 111.33.2.83

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