Nginx Log Top IP

Today access.log

    512 66.249.64.108
    469 45.82.252.92
    310 66.249.64.109
    250 108.165.243.43
    211 216.244.66.241
    196 14.153.240.22
    191 66.249.64.110
    189 14.153.205.36
    185 223.99.125.94
    175 183.238.149.14
    174 14.155.212.233
    162 183.238.246.138
    154 183.239.175.174
    150 14.155.225.217
    150 120.237.85.78
    146 14.155.182.174
    135 27.27.233.222
    112 182.243.108.64
    112 14.155.228.116
    107 14.153.218.16

Yesterday access.log.1

    577 66.249.65.172
    419 66.249.65.173
    321 8.137.111.137
    301 217.182.175.222
    288 66.249.65.174
    273 223.99.125.94
    245 135.181.79.106
    203 66.249.64.108
    188 171.104.83.69
    175 27.27.233.222
    160 20.112.232.23
    148 120.229.48.122
    143 111.33.2.83
    138 171.105.200.195
    121 117.90.83.196
    120 172.233.75.10
    114 121.228.69.80
    110 39.144.108.117
    106 117.153.143.134
    100 180.130.233.192

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