VPS侦探论坛

 找回密码
 注册
查看: 3884|回复: 6

[Apache] nginx 能否禁IP

[复制链接]
发表于 2018-8-6 13:54:59 | 显示全部楼层 |阅读模式

查看了一下nginx的日志,发现有一些IP在一秒内有上百个访问日志
  1. 22.39.58.17 - - [01/Aug/2018:22:34:41 +0800] "HEAD /1cnn%7Bext%7D HTTP/1.1" 444 0 "http://www.xxx.com/1cnn{ext}" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" 10.12.17.17 0.000 - - -
  2. 22.39.58.17 - - [01/Aug/2018:22:34:41 +0800] "HEAD /2cnn%7Bext%7D HTTP/1.1" 444 0 "http://www.xxx.com/2cnn{ext}" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" 10.12.17.27 0.000 - - -
  3. 22.39.58.17 - - [01/Aug/2018:22:34:41 +0800] "HEAD /3cnn%7Bext%7D HTTP/1.1" 444 0 "http://www.xxx.com/3cnn{ext}" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" 10.12.17.37 0.000 - - -
  4. 22.39.58.17 - - [01/Aug/2018:22:34:41 +0800] "HEAD /4cnn%7Bext%7D HTTP/1.1" 444 0 "http://www.xxx.com/4cnn{ext}" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" 10.12.17.47 0.000 - - -
  5. 22.39.58.17 - - [01/Aug/2018:22:34:41 +0800] "HEAD /5cnn%7Bext%7D HTTP/1.1" 444 0 "http://www.xxx.com/5cnn{ext}" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" 10.12.17.57 0.000 - - -
  6. 22.39.58.17 - - [01/Aug/2018:22:34:41 +0800] "HEAD /6cnn%7Bext%7D HTTP/1.1" 444 0 "http://www.xxx.com/6cnn{ext}" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" 10.12.17.67 0.000 - - -
  7. 22.39.58.17 - - [01/Aug/2018:22:34:41 +0800] "HEAD /7cnn%7Bext%7D HTTP/1.1" 444 0 "http://www.xxx.com/7cnn{ext}" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" 10.12.17.77 0.000 - - -
  8. 22.39.58.17 - - [01/Aug/2018:22:34:41 +0800] "HEAD /8cnn%7Bext%7D HTTP/1.1" 444 0 "http://www.xxx.com/8cnn{ext}" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" 10.12.17.87 0.000 - - -
复制代码


,显然这是不正常的,用nginx能否自动禁止掉这些(按条件,一秒内达多少次访问的同一地址请求)IP呢?用nginx屏蔽IP的话还得重启?nginx应该不能直接使用到iptables吧
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2018-8-6 20:12:13 | 显示全部楼层


上面日志上都已经显示444了,不需要处理
要屏蔽掉head 之类的http方法可以论坛搜索: 屏蔽 http 方法
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2018-8-9 15:26:20 | 显示全部楼层

原帖由 licess 于 2018-8-6 20:12 发表
上面日志上都已经显示444了,不需要处理
要屏蔽掉head 之类的http方法可以论坛搜索: 屏蔽 http 方法
已在NGINX文件中添加了 if ($request_method !~* GET|POST|HEAD) {return 403;}
但在日志中依然发现了这样的访问:
180.97.106.39 - - [09/Aug/2018:03:03:51 +0800] "\x05\x02\x00\x02" 400 166 "-" "-" - 4.170 - - -

120.132.3.65 - - [09/Aug/2018:09:26:34 +0800] "\x00\x9C\x00\x01\x1A+<M\x00\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x03\xFF\xFF\x00\x01local\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00cananian\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 400 166 "-" "-" - 0.014 - - -

......
像这些的都是什么访问格式?如何禁止?
这样添加的内容不对?
server{
        listen 80;
        server_name abc.def.com;           //在下面添加不对?nginx -t显示正确
        if ($request_method !~* GET|POST|HEAD) {
                return 403;
        }
        index index.html index.php;
        root /home/abc;
        error_page 404 /404.html;
        error_page 500 502 503 504 /50x.html;
        include enable-php.conf;
        location /favicon.ico{
                log_not_found off;
                access_log off;
        }
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2018-8-10 18:14:44 | 显示全部楼层

回复 3# 的帖子




这个没办法,没有具体的http方法可能是扫描漏洞之类的
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
发表于 2019-1-28 17:00:07 | 显示全部楼层

回复 1# 的帖子


试试fail2ban

军哥运维代购:http://shop63846532.taobao.com/

发表于 2019-5-26 15:34:04 | 显示全部楼层

看看,了解一下
发表于 2019-6-1 12:43:48 | 显示全部楼层

我用 fail2ban+Firewalld 限制IP 访问量


补充内容 (2019-6-1 12:58):
https://www.itbiji.net/archives/850.html
可以了解下
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-5-5 04:55 , Processed in 0.027238 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表