zoukankan      html  css  js  c++  java
  • nginx异常访问处理

    前言:

      公司的nginx服务器总会有一些奇奇怪怪的通ip大量访问记录,总会有奇奇怪怪的人想谋害我的服务器,害,可以通过日志来进行鉴别,再通过配置拒绝访问来应对

    1、查看日志中异常访问的ip记录:

    nginx作为业务服务器:

    sudo cat /var/log/nginx/access.log | grep "2020-10-14" | awk '{print $1}' | sort | uniq -c | sort -nrk 1 | head -n 10

    nginx作为代理服务器:

    sudo cat access.log |grep "2020-10-15"| awk -F """ '{print $8}'| sort | uniq -c | sort -nrk 1 | head -n 10
       4885 116.114.21.4
       2250 223.223.179.130
       1097 101.227.1.197
        918 101.227.1.196
        776 101.227.1.199
        755 101.227.1.198
        188 47.103.47.166
        187 47.92.3.182
        186 120.79.161.84
        136 1.45.28.118

    2.将它们统统加入拒绝访问列表里:

    cd /etc/nginx/conf.d/
    sudo vi blackIP.conf     添加内容如下
    
    # 禁止访问IP
    deny 被禁止IP1;
    deny 被禁止IP2;
    执行命令:
    
    sudo nginx -t
    sudo nginx -s reload

    ok,世界清净了

  • 相关阅读:
    Best Time to Buy and Sell Stock III
    Valid Palindrome
    Longest Substring Without Repeating Characters
    Copy List with Random Pointer
    Add Two Numbers
    Recover Binary Search Tree
    Anagrams
    ZigZag Conversion
    Merge k Sorted Lists
    Distinct Subsequences
  • 原文地址:https://www.cnblogs.com/xiaoyuxixi/p/13606509.html
Copyright © 2011-2022 走看看