美文网首页nginx
Nginx屏蔽某ip/网段访问

Nginx屏蔽某ip/网段访问

作者: Mark87 | 来源:发表于2016-09-12 23:34 被阅读30次

主要是为了防止蜘蛛采集或别人攻击,具体步骤如下:

在nginx配置目录下,新建deny.conf文件,如下所示:

[root@mail conf.d]# pwd

/etc/nginx/conf.d

[root@mail conf.d]# ll

-rw-r--r--. 1 root root   19  2月 22 15:28 deny.conf

[root@mail conf.d]# cat deny.conf

deny 123.7.84.160;

其中:

deny 123.7.84.160; #屏蔽123.7.84.160

deny 123.7.84.0/24; #屏蔽123.7.84.1 ~ 123.7.84.255整个网段IP

再让nginx.conf加载此配置文件,如下所示(nginx1.x默认会加载/etc/nginx/conf.d/下的所有配置文件):

[root@mail nginx]# pwd

/etc/nginx

[root@mail nginx]# ll

总用量 36

drwxr-xr-x. 2 root root 4096  2月 22 15:28 conf.d

-rw-r--r--. 1 root root  964 12月 12 00:57 fastcgi_params

-rw-r--r--. 1 root root 2837 12月 12 00:57 koi-utf

-rw-r--r--. 1 root root 2223 12月 12 00:57 koi-win

-rw-r--r--. 1 root root 3463 12月 12 00:57 mime.types

-rw-r--r--. 1 root root 1052  2月  6 15:22 nginx.conf

-rw-r--r--. 1 root root  596 12月 12 00:57 scgi_params

-rw-r--r--. 1 root root  623 12月 12 00:57 uwsgi_params

-rw-r--r--. 1 root root 3610 12月 12 00:57 win-utf

[root@mail nginx]# cat nginx.conf

..........(以上省略)

http {

include/etc/nginx/conf.d/*.conf;

..........(以下省略)

}

相关文章

  • Nginx屏蔽某ip/网段访问

    主要是为了防止蜘蛛采集或别人攻击,具体步骤如下: 在nginx配置目录下,新建deny.conf文件,如下所示: ...

  • 华为交换机配置ACL

    1、拒绝某单个ip或网段访问某单个ip或网段或端口 1、编辑acl acl号 ...

  • Nginx 查看所有访问IP和封禁IP

    1、统计access.log(/var/log/nginx)中所有IP和访问次数 2、屏蔽IP

  • nginx限制地址访问ip限制

    屏蔽单个ip访问 允许单个ip访问 屏蔽所有ip访问 允许所有ip访问 屏蔽ip段访问 允许ip段访问 配置说明新...

  • 彻底禁止某IP访问Linux

    彻底禁止某IP访问: #屏蔽单个IP的命令是 iptables-IINPUT-s123.45.6.7-jDROP ...

  • Centos 7.2 安装Nginx

    添加CentOS 7 Nginx yum资源库 安装nginx 启动Nginx ip访问如果ip访问不了,查看防火...

  • 如何屏蔽某IP地址访问网站

    最近发现网站恶意攻击频率较高,登录服务器管理后台,发现某些IP持续性地恶意访问我的站点,而且都是一些不存在的页面或...

  • Python运维中八个最常用的脚本!

    一、判断是否是一个目录 二、系统内存与磁盘检测 三、统计nginx日志前十ip访问量并以柱状图显示 四、查看网段里...

  • gitlab限制IP网段访问

    gitlab默认自带Nginx,可以通过修改/etc/gitlab/gitlab.rb配置文件来实现1、查看git...

  • Nginx访问静态资源

    Nginx访问静态资源 即通过IP:端口/文件名 访问文件实现. 修改Nginx配置 重新加载Nginx 上传文件测试

网友评论

    本文标题:Nginx屏蔽某ip/网段访问

    本文链接:https://www.haomeiwen.com/subject/jbqmettx.html