Nginx Log Top IP

Today access.log

     60 111.67.96.136
     47 57.141.3.18
     47 57.141.3.13
     45 57.141.3.11
     43 57.141.3.16
     39 57.141.3.8
     38 57.141.3.2
     35 57.141.3.22
     33 57.141.3.15
     29 57.141.3.27
     28 57.141.3.14
     27 57.141.3.23
     27 57.141.3.17
     26 57.141.3.9
     26 57.141.3.20
     25 57.141.3.6
     25 57.141.3.4
     25 119.133.211.67
     24 57.141.3.5
     24 27.38.222.235

Yesterday access.log.1

    375 66.249.66.68
    337 66.249.66.67
    333 66.249.66.69
    304 27.38.222.235
    254 111.67.96.136
    170 217.113.194.251
    166 182.138.126.90
    163 14.153.247.247
    146 182.84.19.91
    139 217.113.194.184
    132 171.104.83.127
    126 114.95.111.36
    119 172.233.75.10
    115 216.244.66.241
    108 217.113.194.182
    108 14.155.232.74
    105 195.179.229.55
    105 171.105.200.248
    104 217.113.194.188
    101 217.113.194.183

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