论坛风格切换
  • 15825阅读
  • 0回复

[linux服务器]nginx被cc攻击了怎么解决 [复制链接]

上一主题 下一主题
离线云天河
 

发帖
52
金币
186
威望
36
只看楼主 倒序阅读 使用道具 楼主  发表于: 2017-04-10
关键词: Array
查询一个时间,哪些ip访问量最多
grep '05/Apr/2017:14:27' /home/logs/nginx/access_main.log|awk '{print $NF}'| sort | uniq -c | sort -nr | head -n 10

查询ip在干吗
grep '201.161.174.64' /home/logs/nginx/access_main.log |more

如果这个ip不正确
到/home/shell/fw.sh里面,把这个ip屏蔽掉。
/sbin/iptables -I INPUT -s 201.161.174.64 -j DROP

然后重启防火墙
/home/shell/fw.sh

nginx的log_format一般这样写
  1.         log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
  2.                 '$status $body_bytes_sent "$http_referer" '
  3.                 '"responsetime":$request_time '
  4.                 '"upstreamtime":"$upstream_response_time" '
  5.                 '"$http_user_agent" $http_x_forwarded_for $remote_addr';


快速回复
限100 字节
如果您提交过一次失败了,可以用”恢复数据”来恢复帖子内容
 
提到某人:
选择好友
上一个 下一个