Nginx Log Top IP

Today access.log

    644 20.191.255.21
    557 183.238.246.138
    550 14.155.234.79
    514 204.188.217.129
    478 13.79.174.21
    393 14.153.241.208
    355 66.249.74.135
    300 62.84.180.29
    271 66.249.74.136
    247 14.153.241.117
    194 120.219.236.48
    182 66.249.74.137
    177 122.5.15.214
    166 122.191.195.92
    154 14.155.190.202
    151 216.244.66.241
    137 103.194.187.98
    133 119.4.167.229
    114 112.44.229.41
    111 27.27.234.54

Yesterday access.log.1

    716 14.155.190.202
    679 183.238.246.138
    565 66.249.79.236
    503 66.249.79.237
    478 52.169.16.180
    478 52.164.250.212
    441 14.153.237.194
    437 14.155.234.79
    429 136.243.228.195
    416 216.244.66.241
    340 66.249.74.135
    290 66.249.79.238
    289 14.153.241.221
    248 65.108.128.54
    219 66.249.74.136
    205 111.124.234.72
    204 223.99.125.94
    186 27.27.234.54
    171 121.10.198.7
    135 89.208.249.39

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