linux如何禁止频繁访问的ip访问nginx
发表于:2024-10-06 作者:千家信息网编辑
千家信息网最后更新 2024年10月06日,这篇文章主要为大家展示了"linux如何禁止频繁访问的ip访问nginx",内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下"linux如何禁止频繁访问的ip访问
千家信息网最后更新 2024年10月06日linux如何禁止频繁访问的ip访问nginx
这篇文章主要为大家展示了"linux如何禁止频繁访问的ip访问nginx",内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下"linux如何禁止频繁访问的ip访问nginx"这篇文章吧。
实验环境
版本:redhat6.5
ip:172.16.1.100,172.16.10
软件:nginx
172.16.1.10部署nginx
[root@localhost tools]# lsnginx-1.11.2.tar.gz[root@localhost tools]# yum install gcc gcc-c++ make automake autoconf libtool pcre* zlib openssl openssl-devel[root@localhost tools]# tar xf nginx-1.11.2.tar.gz [root@localhost tools]# lsnginx-1.11.2 nginx-1.11.2.tar.gz[root@localhost tools]# cd nginx-1.11.2[root@localhost nginx-1.11.2]# lsauto CHANGES CHANGES.ru conf configure contrib html LICENSE man README src[root@localhost nginx-1.11.2]# ./configure[root@localhost nginx-1.11.2]# make[root@localhost nginx-1.11.2]# make install
测试nginx服务
[root@localhost ~]# curl -I 172.16.1.100HTTP/1.1 200 OKServer: nginx/1.11.2Date: Mon, 17 Aug 2020 09:36:29 GMTContent-Type: text/htmlContent-Length: 15Last-Modified: Mon, 17 Aug 2020 09:36:19 GMTConnection: keep-aliveETag: "5f3a4f93-f"Accept-Ranges: bytes
nginx 可以正常访问。
接下来,假设172.16.1.100是黑客主机,频繁访问nginx服务
模拟172.16.1.100访问10次172.16.1.10
172.16.1.100
[root@localhost ~]# ab -c 1 -n 10 http://172.16.1.10/This is ApacheBench, Version 2.3 Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/Licensed to The Apache Software Foundation, http://www.apache.org/Benchmarking 172.16.1.10 (be patient).....doneServer Software: nginx/1.11.2Server Hostname: 172.16.1.10Server Port: 80Document Path: /Document Length: 612 bytesConcurrency Level: 1Time taken for tests: 0.016 secondsComplete requests: 10Failed requests: 0Write errors: 0Total transferred: 8450 bytesHTML transferred: 6120 bytesRequests per second: 617.02 [#/sec] (mean)Time per request: 1.621 [ms] (mean)Time per request: 1.621 [ms] (mean, across all concurrent requests)Transfer rate: 509.16 [Kbytes/sec] receivedConnection Times (ms) min mean[+/-sd] median maxConnect: 0 1 0.3 0 1Processing: 1 1 0.3 1 2Waiting: 0 1 0.3 1 1Total: 1 1 0.5 1 2ERROR: The median and mean for the initial connection time are more than twice the standard deviation apart. These results are NOT reliable.Percentage of the requests served within a certain time (ms) 50% 1 66% 1 75% 1 80% 2 90% 2 95% 2 98% 2 99% 2 100% 2 (longest request)
查看nginx日志
172.16.1.10
[root@localhost ~]# tail /usr/local/nginx/logs/access.log172.16.1.100 - - [26/Jul/2020:05:58:24 +0800] "GET / HTTP/1.0" 200 612 "-" "ApacheBench/2.3"172.16.1.100 - - [26/Jul/2020:05:58:24 +0800] "GET / HTTP/1.0" 200 612 "-" "ApacheBench/2.3"172.16.1.100 - - [26/Jul/2020:05:58:24 +0800] "GET / HTTP/1.0" 200 612 "-" "ApacheBench/2.3"172.16.1.100 - - [26/Jul/2020:05:58:24 +0800] "GET / HTTP/1.0" 200 612 "-" "ApacheBench/2.3"172.16.1.100 - - [26/Jul/2020:05:58:24 +0800] "GET / HTTP/1.0" 200 612 "-" "ApacheBench/2.3"172.16.1.100 - - [26/Jul/2020:05:58:24 +0800] "GET / HTTP/1.0" 200 612 "-" "ApacheBench/2.3"172.16.1.100 - - [26/Jul/2020:05:58:24 +0800] "GET / HTTP/1.0" 200 612 "-" "ApacheBench/2.3"172.16.1.100 - - [26/Jul/2020:05:58:24 +0800] "GET / HTTP/1.0" 200 612 "-" "ApacheBench/2.3"172.16.1.100 - - [26/Jul/2020:05:58:24 +0800] "GET / HTTP/1.0" 200 612 "-" "ApacheBench/2.3"172.16.1.100 - - [26/Jul/2020:05:58:24 +0800] "GET / HTTP/1.0" 200 612 "-" "ApacheBench/2.3"
由此可见,一秒钟之内172.16.1.100访问了nginx10次,接下来禁止掉这个问题ip
通过iptables限制ip访问
172.16.1.10
[root@localhost ~]# iptables -I INPUT -s 172.16.1.100 -ptcp --dport 80 -j DROP
172.16.1.100
[root@localhost ~]# curl 172.16.1.10curl: (7) Failed connect to 172.16.1.10:80; 连接超时
此时172.16.1.100再也不能访问nginx
nginx配置文件限制
172.16.1.10
172.16.1.100
[root@localhost ~]# curl -I 172.16.1.10HTTP/1.1 403 ForbiddenServer: nginx/1.11.2Date: Sat, 25 Jul 2020 23:12:06 GMTContent-Type: text/htmlContent-Length: 169Connection: keep-alive
以上是"linux如何禁止频繁访问的ip访问nginx"这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注行业资讯频道!
频繁
内容
篇文章
接下来
学习
帮助
服务
限制
主机
文件
日志
易懂
更多
条理
版本
环境
由此
由此可见
知识
编带
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
杭州赤橙网络技术
江苏贸易进口软件服务器虚拟主机
宜兴挑选计算机网络技术创新服务
担保公司 数据库
国家信息中心网络安全评测师
宠物商店业务 思维导图 数据库
新华三双电源服务器
外文数据库开放
怎么找回数据库密码
服务器财务管理系统
软件开发成本包括哪些东西
网络安全防护技术不够
重庆网络技术开发
软件开发常用专业术语
汽车车牌实时数据库
合肥软件开发经理
榆林核酸检测系统提示数据库
昌平购物软件开发
宝可梦服务器制作教程
饥饿恐惧服务器停止回应
剑网1华为服几个服务器
手机app服务器关闭怎么登录
车载软件开发和阶段输入输出
云计算软件开发工程师怎么样
如何查询服务器中的人
金城数据库
中国网络安全法对外企的影响
怎么让服务器的负载卡顿
网络安全ppt动画
工业排版规划软件开发